cleanAllTablesData method
Removes every row from every user-defined table of the database. The tables themselves are kept.
Implementation
Future<void> cleanAllTablesData() async {
final List<String> tables = await getAColumnFromWithTableName<String>(
'name',
'sqlite_master',
afterWhere:
"type='table' AND name NOT LIKE 'sqlite_%' AND name <> 'b012_meta'",
);
final SqlExecutor executor = await _executor();
await executor.transaction((SqlExecutor tx) async {
// Enforced foreign keys are checked at commit, once every table is
// empty, whatever the order of the tables.
await tx.execute('PRAGMA defer_foreign_keys = ON');
for (final String table in tables) {
await tx.execute('DELETE FROM ${quoteIdentifier(table)}');
}
});
}