addIndex method

  1. @override
void addIndex(
  1. String name,
  2. List<String> columns,
  3. IndexType type
)

Implementation

@override
void addIndex(String name, List<String> columns, IndexType type) {
  String indexType = '';

  switch (type) {
    case IndexType.primaryKey:
      indexType = 'PRIMARY KEY';
      break;
    case IndexType.unique:
      indexType = 'CONSTRAINT "$name" UNIQUE';
      break;
    case IndexType.standardIndex:
    case IndexType.none:
      // not working with postgres
      return;
  }

  // mask the column names, is more safety
  columns.map((column) => '"$column"');

  _stack.add('ADD $indexType (${columns.join(',')})');
}