File tree 2 files changed +10
-6
lines changed
2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -135,14 +135,16 @@ class AppDatabase extends _$AppDatabase {
135
135
},
136
136
);
137
137
138
+ Future <void > _createLatestSchema (Migrator m) async {
139
+ await m.createAll ();
140
+ // Corresponds to `from4to5` above.
141
+ await into (globalSettings).insert (GlobalSettingsCompanion ());
142
+ }
143
+
138
144
@override
139
145
MigrationStrategy get migration {
140
146
return MigrationStrategy (
141
- onCreate: (Migrator m) async {
142
- await m.createAll ();
143
- // Corresponds to `from4to5` above.
144
- await into (globalSettings).insert (GlobalSettingsCompanion ());
145
- },
147
+ onCreate: _createLatestSchema,
146
148
onUpgrade: (Migrator m, int from, int to) async {
147
149
if (from > to) {
148
150
// This should only ever happen in dev. As a dev convenience,
@@ -157,7 +159,7 @@ class AppDatabase extends _$AppDatabase {
157
159
assert (to == latestSchemaVersion);
158
160
159
161
await _dropAll (m);
160
- await m. createAll ( );
162
+ await _createLatestSchema (m );
161
163
return ;
162
164
}
163
165
assert (1 <= from && from <= to && to <= latestSchemaVersion);
Original file line number Diff line number Diff line change @@ -147,6 +147,8 @@ void main() {
147
147
// does not have the extra tables and columns.
148
148
final after = AppDatabase (schema.newConnection ());
149
149
await verifier.migrateAndValidate (after, toVersion, validateDropped: true );
150
+ // Check that a custom migration/setup step of ours got run too.
151
+ check (await after.getGlobalSettings ()).themeSetting.isNull ();
150
152
await after.close ();
151
153
});
152
154
You can’t perform that action at this time.
0 commit comments