@@ -87,23 +87,21 @@ class AppDatabase extends _$AppDatabase {
87
87
int get schemaVersion => latestSchemaVersion;
88
88
89
89
static Future <void > _dropAndCreateAll (Migrator m) async {
90
- await m.database.transaction (() async {
91
- final query = m.database.customSelect (
92
- "SELECT name FROM sqlite_master WHERE type='table'" );
93
- for (final row in await query.get ()) {
94
- final data = row.data;
95
- final tableName = data['name' ] as String ;
96
- // Skip sqlite-internal tables. See for comparison:
97
- // https://www.sqlite.org/fileformat2.html#intschema
98
- // https://github.com/simolus3/drift/blob/0901c984a/drift_dev/lib/src/services/schema/verifier_common.dart#L9-L22
99
- if (tableName.startsWith ('sqlite_' )) continue ;
100
- // No need to worry about SQL injection; this table name
101
- // was already a table name in the database, not something
102
- // that should be affected by user data.
103
- await m.database.customStatement ('DROP TABLE $tableName ' );
104
- }
105
- await m.createAll ();
106
- });
90
+ final query = m.database.customSelect (
91
+ "SELECT name FROM sqlite_master WHERE type='table'" );
92
+ for (final row in await query.get ()) {
93
+ final data = row.data;
94
+ final tableName = data['name' ] as String ;
95
+ // Skip sqlite-internal tables. See for comparison:
96
+ // https://www.sqlite.org/fileformat2.html#intschema
97
+ // https://github.com/simolus3/drift/blob/0901c984a/drift_dev/lib/src/services/schema/verifier_common.dart#L9-L22
98
+ if (tableName.startsWith ('sqlite_' )) continue ;
99
+ // No need to worry about SQL injection; this table name
100
+ // was already a table name in the database, not something
101
+ // that should be affected by user data.
102
+ await m.database.customStatement ('DROP TABLE $tableName ' );
103
+ }
104
+ await m.createAll ();
107
105
}
108
106
109
107
static final MigrationStepWithVersion _migrationSteps = migrationSteps (
@@ -122,16 +120,14 @@ class AppDatabase extends _$AppDatabase {
122
120
// This migration ensures there is a row in GlobalSettings.
123
121
// (If the app already ran at schema 3 or 4, there will be;
124
122
// if not, there won't be before this point.)
125
- await m.database.transaction (() async {
126
- final rows = await m.database.select (schema.globalSettings).get ();
127
- if (rows.isEmpty) {
128
- await m.database.into (schema.globalSettings).insert (
129
- // No field values; just use the defaults for both fields.
130
- // (This is like `GlobalSettingsCompanion.insert()`, but
131
- // without dependence on the current schema.)
132
- RawValuesInsertable ({}));
133
- }
134
- });
123
+ final rows = await m.database.select (schema.globalSettings).get ();
124
+ if (rows.isEmpty) {
125
+ await m.database.into (schema.globalSettings).insert (
126
+ // No field values; just use the defaults for both fields.
127
+ // (This is like `GlobalSettingsCompanion.insert()`, but
128
+ // without dependence on the current schema.)
129
+ RawValuesInsertable ({}));
130
+ }
135
131
},
136
132
);
137
133
0 commit comments