Skip to content

Commit 7111fe6

Browse files
committed
Merge remote-tracking branch 'pr/1590'
2 parents 4394341 + 48bd148 commit 7111fe6

File tree

10 files changed

+1332
-4
lines changed

10 files changed

+1332
-4
lines changed

lib/model/database.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class GlobalSettings extends Table {
3131
Column<String> get markReadOnScroll => textEnum<MarkReadOnScrollSetting>()
3232
.nullable()();
3333

34+
Column<String> get legacyUpgradeState => textEnum<LegacyUpgradeState>()
35+
.nullable()();
36+
3437
// If adding a new column to this table, consider whether [BoolGlobalSettings]
3538
// can do the job instead (by adding a value to the [BoolGlobalSetting] enum).
3639
// That way is more convenient, when it works, because
@@ -126,7 +129,7 @@ class AppDatabase extends _$AppDatabase {
126129
// information on using the build_runner.
127130
// * Write a migration in `_migrationSteps` below.
128131
// * Write tests.
129-
static const int latestSchemaVersion = 8; // See note.
132+
static const int latestSchemaVersion = 9; // See note.
130133

131134
@override
132135
int get schemaVersion => latestSchemaVersion;
@@ -189,13 +192,23 @@ class AppDatabase extends _$AppDatabase {
189192
await m.addColumn(schema.globalSettings,
190193
schema.globalSettings.markReadOnScroll);
191194
},
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+
}
192204
);
193205

194206
Future<void> _createLatestSchema(Migrator m) async {
195207
assert(debugLog('Creating DB schema from scratch.'));
196208
await m.createAll();
197209
// Corresponds to `from4to5` above.
198210
await into(globalSettings).insert(GlobalSettingsCompanion());
211+
// Corresponds to (but differs from) part of `from8To9` above.
199212
await migrateLegacyAppData(this);
200213
}
201214

lib/model/database.g.dart

Lines changed: 104 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)