@@ -31,6 +31,9 @@ class GlobalSettings extends Table {
31
31
Column <String > get markReadOnScroll => textEnum <MarkReadOnScrollSetting >()
32
32
.nullable ()();
33
33
34
+ Column <String > get legacyUpgradeState => textEnum <LegacyUpgradeState >()
35
+ .nullable ()();
36
+
34
37
// If adding a new column to this table, consider whether [BoolGlobalSettings]
35
38
// can do the job instead (by adding a value to the [BoolGlobalSetting] enum).
36
39
// That way is more convenient, when it works, because
@@ -126,7 +129,7 @@ class AppDatabase extends _$AppDatabase {
126
129
// information on using the build_runner.
127
130
// * Write a migration in `_migrationSteps` below.
128
131
// * Write tests.
129
- static const int latestSchemaVersion = 8 ; // See note.
132
+ static const int latestSchemaVersion = 9 ; // See note.
130
133
131
134
@override
132
135
int get schemaVersion => latestSchemaVersion;
@@ -189,13 +192,23 @@ class AppDatabase extends _$AppDatabase {
189
192
await m.addColumn (schema.globalSettings,
190
193
schema.globalSettings.markReadOnScroll);
191
194
},
195
+ from8To9: (m, schema) async {
196
+ await m.addColumn (schema.globalSettings,
197
+ schema.globalSettings.legacyUpgradeState);
198
+ // Earlier versions of this app weren't built to be installed over
199
+ // the legacy app. So if upgrading from an earlier version of this app,
200
+ // assume there wasn't also the legacy app before that.
201
+ await m.database.update (schema.globalSettings).write (
202
+ RawValuesInsertable ({'legacy_upgrade_state' : Constant ('noLegacy' )}));
203
+ }
192
204
);
193
205
194
206
Future <void > _createLatestSchema (Migrator m) async {
195
207
assert (debugLog ('Creating DB schema from scratch.' ));
196
208
await m.createAll ();
197
209
// Corresponds to `from4to5` above.
198
210
await into (globalSettings).insert (GlobalSettingsCompanion ());
211
+ // Corresponds to (but differs from) part of `from8To9` above.
199
212
await migrateLegacyAppData (this );
200
213
}
201
214
0 commit comments