index method

void index(
  1. String column, {
  2. String? indexName,
})

Add an index to a column

If a name is given the index name will be set to it, otherwise it is infered from the column name

Implementation

void index(String column, {String? indexName}) {
  String? idxName = column;
  switch (indexName != null) {
    case true:
      idxName = indexName;
      break;
    default:
      idxName = "idx_$column";
  }
  final q = "CREATE UNIQUE INDEX IF NOT EXISTS $idxName ON $name($column)";
  _queries.add(q);
}