createIndex method

Future<void> createIndex({
  1. required String name,
  2. required String table,
  3. required List<String> columns,
  4. bool unique = false,
})

Helper to create index (skips if exists)

Implementation

Future<void> createIndex({
  required String name,
  required String table,
  required List<String> columns,
  bool unique = false,
}) async {
  final exists = await schemaManager.indexExists(name, table);
  if (exists) return;

  final uniqueKeyword = unique ? 'UNIQUE ' : '';
  final sql =
      'CREATE ${uniqueKeyword}INDEX IF NOT EXISTS $name ON $table (${columns.join(', ')});';
  await connection.execute(sql);
}