onDbCreate method
FutureOr<void>
onDbCreate(
- Database db,
- int version
)
inherited
Implementation
FutureOr<void> onDbCreate(Database db, int version) async {
// Run the CREATE TABLE statement on the database.
await db.transaction((txn) async {
var batch = txn.batch();
List<String> allQueries = [];
for (var element in tables) {
final query = element.createTable(version);
allQueries.add(query);
batch.execute(query);
}
await batch.commit(noResult: true);
_logBatchResult('onDbCreate', allQueries,
'Database tables created with version from $version');
});
await db.transaction((txn) async {
var batch = txn.batch();
List<String> allQueries = [];
for (var element in tables) {
final queries = element.onCreateComplete(version);
if (queries.isNotEmpty == true) {
allQueries.addAll(queries);
for (var query in queries) {
batch.execute(query);
}
}
}
await batch.commit(noResult: true);
_logBatchResult('After onDbCreate', allQueries, null);
});
}