@@ -73,6 +73,16 @@ class BoolGlobalSettings extends Table {
73
73
Set <Column <Object >>? get primaryKey => {name};
74
74
}
75
75
76
+ @DataClassName ('IntGlobalSettingRow' )
77
+ class IntGlobalSettings extends Table {
78
+ TextColumn get name => text ()();
79
+
80
+ IntColumn get value => integer ()();
81
+
82
+ @override
83
+ Set <Column <Object >>? get primaryKey => {name};
84
+ }
85
+
76
86
/// The table of [Account] records in the app's database.
77
87
class Accounts extends Table {
78
88
/// The ID of this account in the app's local database.
@@ -116,7 +126,7 @@ class UriConverter extends TypeConverter<Uri, String> {
116
126
@override Uri fromSql (String fromDb) => Uri .parse (fromDb);
117
127
}
118
128
119
- @DriftDatabase (tables: [GlobalSettings , BoolGlobalSettings , Accounts ])
129
+ @DriftDatabase (tables: [GlobalSettings , BoolGlobalSettings , IntGlobalSettings , Accounts ])
120
130
class AppDatabase extends _$AppDatabase {
121
131
AppDatabase (super .e);
122
132
@@ -129,7 +139,7 @@ class AppDatabase extends _$AppDatabase {
129
139
// information on using the build_runner.
130
140
// * Write a migration in `_migrationSteps` below.
131
141
// * Write tests.
132
- static const int latestSchemaVersion = 9 ; // See note.
142
+ static const int latestSchemaVersion = 10 ; // See note.
133
143
134
144
@override
135
145
int get schemaVersion => latestSchemaVersion;
@@ -200,7 +210,10 @@ class AppDatabase extends _$AppDatabase {
200
210
// assume there wasn't also the legacy app before that.
201
211
await m.database.update (schema.globalSettings).write (
202
212
RawValuesInsertable ({'legacy_upgrade_state' : Constant ('noLegacy' )}));
203
- }
213
+ },
214
+ from9To10: (m, schema) async {
215
+ await m.createTable (schema.intGlobalSettings);
216
+ },
204
217
);
205
218
206
219
Future <void > _createLatestSchema (Migrator m) async {
@@ -256,6 +269,14 @@ class AppDatabase extends _$AppDatabase {
256
269
return result;
257
270
}
258
271
272
+ Future <Map <IntGlobalSetting , int >> getIntGlobalSettings () async {
273
+ return {
274
+ for (final row in await select (intGlobalSettings).get ())
275
+ if (IntGlobalSetting .byName (row.name) case final setting? )
276
+ setting: row.value
277
+ };
278
+ }
279
+
259
280
Future <int > createAccount (AccountsCompanion values) async {
260
281
try {
261
282
return await into (accounts).insert (values);
0 commit comments