@@ -4,6 +4,7 @@ import 'package:drift/remote.dart';
44import 'package:sqlite3/common.dart' ;
55
66import '../log.dart' ;
7+ import 'legacy_app_data.dart' ;
78import 'schema_versions.g.dart' ;
89import '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