Skip to content

Commit 4394341

Browse files
committed
Merge remote-tracking branch 'pr/1588'
2 parents 952aefa + 06546a9 commit 4394341

File tree

3 files changed

+602
-1
lines changed

3 files changed

+602
-1
lines changed

lib/model/database.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:drift/remote.dart';
44
import 'package:sqlite3/common.dart';
55

66
import '../log.dart';
7+
import 'legacy_app_data.dart';
78
import 'schema_versions.g.dart';
89
import 'settings.dart';
910

@@ -191,9 +192,11 @@ class AppDatabase extends _$AppDatabase {
191192
);
192193

193194
Future<void> _createLatestSchema(Migrator m) async {
195+
assert(debugLog('Creating DB schema from scratch.'));
194196
await m.createAll();
195197
// Corresponds to `from4to5` above.
196198
await into(globalSettings).insert(GlobalSettingsCompanion());
199+
await migrateLegacyAppData(this);
197200
}
198201

199202
@override
@@ -205,7 +208,7 @@ class AppDatabase extends _$AppDatabase {
205208
// This should only ever happen in dev. As a dev convenience,
206209
// drop everything from the database and start over.
207210
// TODO(log): log schema downgrade as an error
208-
assert(debugLog('Downgrading schema from v$from to v$to.'));
211+
assert(debugLog('Downgrading DB schema from v$from to v$to.'));
209212

210213
// In the actual app, the target schema version is always
211214
// the latest version as of the code that's being run.
@@ -219,6 +222,7 @@ class AppDatabase extends _$AppDatabase {
219222
}
220223
assert(1 <= from && from <= to && to <= latestSchemaVersion);
221224

225+
assert(debugLog('Upgrading DB schema from v$from to v$to.'));
222226
await m.runMigrationSteps(from: from, to: to, steps: _migrationSteps);
223227
});
224228
}

0 commit comments

Comments
 (0)