-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible unexpected behavior in bdk_chain::migrate_schema
#1767
Comments
Thanks for the great description of this issue. As long as BDK is implementing the DB migration for users I think this is a low risk issue. But still good to have it documented in case anyone wants to implement a better way to do it. |
migrate_schema(&db_tx, ChangeSet::SCHEMA_NAME, &[schema_v1])?; But this is just wrong code right? I don't think this ticket is a bug, but a feature request for performance reasons? However, looking at this, I do have a new thought. If the current (persisted) schema version is greater than the defined schemas, we should probably error out. --> This is the bug. |
Understood. Maybe I'm the only one committing this error, but then, shouldn't we add to
But the notion of "version" for the individual schemas is given by their order in the |
Describe the bug
migrate_schema
skips the firstn
schemas to apply wheren
is the current schema version. That means, if I want to independently apply a new schemak+1
to a database already using schemak
I should create a list ofk+1
schemas (where any string, even empty ones, could be an schema) asmigrate_schema
will skip thek
first anyway.If I don't do that, skip will reach the end of iterator sooner and return another empty iterator, forcing
migrate_schema
to do nothing.So:
applies
schema_v0
.But
applied in a
schema_v0
database does nothing.And
applied in a
schema_v0
database appliesschema_v1
.As there is a workaround for this, I don't think it is a great deal. But I think we should at least document it, if not changed.
To Reproduce
git diff
Expected behavior
schema_v5
when callingmigrate_schema(..., &[schema_v5])
on a database with schemav4
.schema_v4
first if callingmigrate_schema(..., &[schema_v5])
on a database with schemav3
.migrate_schema(..., &[schema_v3])
on a database with schemav4
.schema_v4
,schema_v5
in order and ignoreschema_v3
when callingmigrate_schema(..., &[schema_v4, schema_v3, schema_v5])
on a database with schemav3
.The text was updated successfully, but these errors were encountered: