dvAddColumnFor function

DVAddColumn dvAddColumnFor(
  1. Map<String, Object?> table,
  2. String column
)

The column column of a generated table, as the change that adds it.

Nullable TEXT unless the generator recorded a type for it under columnTypes -- the record version, which has to arrive as NOT NULL DEFAULT 1 so the rows already there can be written at the version they hold.

Implementation

DVAddColumn dvAddColumnFor(Map<String, Object?> table, String column) {
  final Object? types = table['columnTypes'];
  final Object? spec = types is Map ? types[column] : null;
  if (spec is! Map) return DVAddColumn('${table['table']}', column);
  return DVAddColumn(
    '${table['table']}',
    column,
    type: '${spec['type'] ?? 'TEXT'}',
    nullable: spec['nullable'] != false,
    defaultSql: spec['default'] == null ? null : '${spec['default']}',
  );
}