truncateTable method

  1. @override
Future<void> truncateTable(
  1. String tableName
)

Truncates a table, removing all rows and resetting auto-increment counters.

This is more efficient than deleting all rows and properly resets sequences/auto-increment values. Each driver implements this using its native truncate mechanism.

Implementation

@override
Future<void> truncateTable(String tableName) async {
  final connection = await _connection();
  // PostgreSQL supports TRUNCATE TABLE with RESTART IDENTITY
  await connection.execute('TRUNCATE TABLE $tableName RESTART IDENTITY');
}