reset method
Implementation
@override
Future reset() async {
await _init();
var result = await connection
.execute('SELECT path from migrations ORDER BY batch DESC;');
var existing = <String>[];
if (result.rows.isNotEmpty) {
var firstRow = result.rows.first;
existing = firstRow.assoc().values.cast<String>().toList();
}
var toRun = existing.where(migrations.containsKey).toList();
if (toRun.isNotEmpty) {
for (var k in toRun.reversed) {
var migration = migrations[k]!;
var schema = MySqlSchema();
migration.down(schema);
_log.info('Removed "$k" from "migrations" table.');
await schema.run(connection).then((_) {
return connection
.execute('DELETE FROM migrations WHERE path = \'$k\';');
});
}
} else {
_log.warning('Nothing to remove from "migrations" table.');
}
}