declareColumn method
Adds the column name, without a UNIQUE, which SQLite does not add,
but with a unique index of its own, as with a standard index.
Implementation
@override
MigrationColumn declareColumn(String name, Column column) {
if (!_declared.add(name)) {
throw StateError('Cannot redeclare column "$name".');
}
var col = MigrationColumn.from(column);
var table = _currentName;
_statements.add(() {
var buf = StringBuffer(
'ALTER TABLE ${sql.quotePostgresTableName(table)} '
'ADD COLUMN ${sql.quotePostgresIdentifier(name)} '
'${SqliteGenerator.compileColumn(col, constraints: false)};',
);
if (col.indexType case IndexType.unique || IndexType.standardIndex) {
var unique = col.indexType == IndexType.unique;
buf.write(
'\n${compileCreateIndex(columnIndexName(table, name, unique: unique), table, [name], unique: unique)}',
);
}
return buf.toString();
});
return col;
}