File tree 1 file changed +8
-3
lines changed 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,12 @@ class AppDatabase extends _$AppDatabase {
86
86
@override
87
87
int get schemaVersion => latestSchemaVersion;
88
88
89
- static Future <void > _dropAndCreateAll (Migrator m) async {
89
+ /// Drop all tables, indexes, etc., in the database.
90
+ ///
91
+ /// This includes tables that aren't known to the schema, for example because
92
+ /// they were defined by a future (perhaps experimental) version of the app
93
+ /// before switching back to the version currently running.
94
+ static Future <void > _dropAll (Migrator m) async {
90
95
final query = m.database.customSelect (
91
96
"SELECT name FROM sqlite_master WHERE type='table'" );
92
97
for (final row in await query.get ()) {
@@ -101,7 +106,6 @@ class AppDatabase extends _$AppDatabase {
101
106
// that should be affected by user data.
102
107
await m.database.customStatement ('DROP TABLE $tableName ' );
103
108
}
104
- await m.createAll ();
105
109
}
106
110
107
111
static final MigrationStepWithVersion _migrationSteps = migrationSteps (
@@ -152,7 +156,8 @@ class AppDatabase extends _$AppDatabase {
152
156
// in migration tests; we can forego that for testing downgrades.
153
157
assert (to == latestSchemaVersion);
154
158
155
- await _dropAndCreateAll (m);
159
+ await _dropAll (m);
160
+ await m.createAll ();
156
161
return ;
157
162
}
158
163
assert (1 <= from && from <= to && to <= latestSchemaVersion);
You can’t perform that action at this time.
0 commit comments