Skip to content

Welcome dialog on upgrade from legacy app #1590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/model/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class GlobalSettings extends Table {
Column<String> get markReadOnScroll => textEnum<MarkReadOnScrollSetting>()
.nullable()();

Column<String> get legacyUpgradeState => textEnum<LegacyUpgradeState>()
.nullable()();

// If adding a new column to this table, consider whether [BoolGlobalSettings]
// can do the job instead (by adding a value to the [BoolGlobalSetting] enum).
// That way is more convenient, when it works, because
Expand Down Expand Up @@ -126,7 +129,7 @@ class AppDatabase extends _$AppDatabase {
// information on using the build_runner.
// * Write a migration in `_migrationSteps` below.
// * Write tests.
static const int latestSchemaVersion = 8; // See note.
static const int latestSchemaVersion = 9; // See note.

@override
int get schemaVersion => latestSchemaVersion;
Expand Down Expand Up @@ -189,13 +192,23 @@ class AppDatabase extends _$AppDatabase {
await m.addColumn(schema.globalSettings,
schema.globalSettings.markReadOnScroll);
},
from8To9: (m, schema) async {
await m.addColumn(schema.globalSettings,
schema.globalSettings.legacyUpgradeState);
// Earlier versions of this app weren't built to be installed over
// the legacy app. So if upgrading from an earlier version of this app,
// assume there wasn't also the legacy app before that.
await m.database.update(schema.globalSettings).write(
RawValuesInsertable({'legacy_upgrade_state': Constant('noLegacy')}));
}
);

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

Expand Down
106 changes: 104 additions & 2 deletions lib/model/database.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading