Skip to content

Commit f120459

Browse files
committed
db: Store browser preference in database
Signed-off-by: Zixuan James Li <[email protected]>
1 parent ed0afcb commit f120459

10 files changed

+928
-8
lines changed

lib/model/database.dart

+10-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ part 'database.g.dart';
1818
class GlobalSettings extends Table {
1919
Column<String> get themeSetting => textEnum<ThemeSetting>()
2020
.nullable()();
21+
22+
Column<String> get browserPreference => textEnum<BrowserPreference>()
23+
.nullable()();
2124
}
2225

2326
/// The table of [Account] records in the app's database.
@@ -73,6 +76,8 @@ VersionedSchema _getSchema({
7376
return Schema2(database: database);
7477
case 3:
7578
return Schema3(database: database);
79+
case 4:
80+
return Schema4(database: database);
7681
default:
7782
throw Exception('unknown schema version: $schemaVersion');
7883
}
@@ -93,7 +98,7 @@ class AppDatabase extends _$AppDatabase {
9398
// * Write a migration in `onUpgrade` below.
9499
// * Write tests.
95100
@override
96-
int get schemaVersion => 3; // See note.
101+
int get schemaVersion => 4; // See note.
97102

98103
Future<void> _dropAndCreateAll(Migrator m, {
99104
required int schemaVersion,
@@ -145,6 +150,10 @@ class AppDatabase extends _$AppDatabase {
145150
from2To3: (m, schema) async {
146151
await m.createTable(schema.globalSettings);
147152
},
153+
from3To4: (m, schema) async {
154+
await m.addColumn(
155+
schema.globalSettings, schema.globalSettings.browserPreference);
156+
},
148157
));
149158
});
150159
}

lib/model/database.g.dart

+102-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)