compileColumn static method

String compileColumn(
  1. MigrationColumn column
)

Implementation

static String compileColumn(MigrationColumn column) {
  var buf = StringBuffer(columnType(column));

  if (column.isNullable == false) buf.write(' NOT NULL');
  var defaultValue = column.defaultValue;
  if (defaultValue != null) {
    buf.write(' DEFAULT ${compileDefault(defaultValue)}');
  }

  if (column.indexType == IndexType.unique) {
    buf.write(' UNIQUE');
  } else if (column.indexType == IndexType.primaryKey) {
    buf.write(' PRIMARY KEY');
  }

  for (var ref in column.externalReferences) {
    buf.write(' ${compileReference(ref)}');
  }

  return buf.toString();
}