compileCreateIndex function

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

The CREATE INDEX of the index name of the columns of the table table, which may be qualified by its schema, if it does not exist.

Implementation

String compileCreateIndex(
  String name,
  String table,
  List<String> columns, {
  bool unique = false,
}) =>
    'CREATE ${unique ? 'UNIQUE ' : ''}INDEX IF NOT EXISTS '
    '${sql.quotePostgresIdentifier(name)} '
    'ON ${sql.quotePostgresTableName(table)} '
    '(${columns.map((c) => sql.compileIndexColumn(c, sql.quotePostgresPart)).join(',')});';