truncateMigration method
Future<void>
truncateMigration(
)
override
Implementation
@override
Future<void> truncateMigration() async {
final connection = _dbConnection;
final adapter = _adapter;
if (connection == null || adapter == null) {
throw DatabaseException(
'Database connection not established. Call setup() first.',
);
}
final table = adapter.migrationsTable;
try {
if (adapter.supports('sqlite') || adapter.supports('sqlite3')) {
await connection.execute(
'DELETE FROM ${adapter.escapeIdentifier(table)}',
);
} else if (adapter.supports('mongodb') || adapter.supports('mongo')) {
await connection.execute(
jsonEncode({'_vania_migration': 'truncateCollection', 'name': table}),
);
} else {
await connection.execute('TRUNCATE ${adapter.escapeIdentifier(table)}');
}
} catch (e) {
throw DatabaseException('Failed to truncate $table table', e);
}
}