mirror of https://github.com/AMT-Cheif/drift.git
moor_ffi: Only update schema version after migrations
This commit is contained in:
parent
bc1f347498
commit
d1332ff1be
|
@ -260,9 +260,8 @@ class DelegatedDatabase extends QueryExecutor with _ExecutorWithQueryDelegate {
|
|||
// version has already been set during open
|
||||
oldVersion = await versionDelegate.loadSchemaVersion();
|
||||
} else if (versionDelegate is DynamicVersionDelegate) {
|
||||
// set version now
|
||||
oldVersion = await versionDelegate.schemaVersion;
|
||||
await versionDelegate.setSchemaVersion(currentVersion);
|
||||
// Note: We only update the schema version after migrations ran
|
||||
} else {
|
||||
throw Exception('Invalid delegate: $delegate. The versionDelegate getter '
|
||||
'must not subclass DBVersionDelegate directly');
|
||||
|
@ -277,6 +276,11 @@ class DelegatedDatabase extends QueryExecutor with _ExecutorWithQueryDelegate {
|
|||
final openingDetails = OpeningDetails(oldVersion, currentVersion);
|
||||
await user.beforeOpen(_BeforeOpeningExecutor(this), openingDetails);
|
||||
|
||||
if (versionDelegate is DynamicVersionDelegate) {
|
||||
// set version now, after migrations ran successfully
|
||||
await versionDelegate.setSchemaVersion(currentVersion);
|
||||
}
|
||||
|
||||
delegate.notifyDatabaseOpened(openingDetails);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue