Table of Contents

Method AddColumn

Namespace
YndigoBlue.Velocity.Model
Assembly
YndigoBlue.Velocity.dll

AddColumn(string, DataType, bool, bool, int, byte, byte)

Adds a new column to an already-deployed table as a schema migration operation.

public Column AddColumn(string name, DataType dataType, bool notNull = false, bool autoGenerate = false, int size = 0, byte precision = 0, byte scale = 0)

Parameters

name string

The name of the column.

dataType DataType

The data type of the column.

notNull bool

Whether the column should have a NOT NULL constraint. Defaults to false.

autoGenerate bool

Whether the column value should be auto-generated (identity/sequence). Defaults to false.

size int

The size of the column for variable-length types such as VarChar. Defaults to 0 (no size limit).

precision byte

The total number of significant digits for numeric types. Defaults to 0.

scale byte

The number of digits to the right of the decimal point for numeric types. Defaults to 0.

Returns

Column

The newly created Column with SchemaUpdate set to true.

Remarks

This method is for schema migration — adding a column to a table that already exists in the database. It automatically sets SchemaUpdate to true, which causes UpdateSchema(Schema, bool) to issue an ALTER TABLE ADD COLUMN statement for this column.

For defining columns as part of an initial schema deployment, use CreateColumn(string, DataType, bool, bool, int, byte, byte) instead.

AddColumn(string, DataType, DefaultConstraintType, IDefaultItem, bool, bool, int, byte, byte)

Adds a new column to an already-deployed table as a schema migration operation, with a default value applied to existing rows.

public Column AddColumn(string name, DataType dataType, DefaultConstraintType existingRowType, IDefaultItem existingRowValue, bool notNull = false, bool autoGenerate = false, int size = 0, byte precision = 0, byte scale = 0)

Parameters

name string

The name of the column.

dataType DataType

The data type of the column.

existingRowType DefaultConstraintType

The type of default value to apply to existing rows.

existingRowValue IDefaultItem

The default value item to apply to existing rows.

notNull bool

Whether the column should have a NOT NULL constraint. Defaults to false.

autoGenerate bool

Whether the column value should be auto-generated (identity/sequence). Defaults to false.

size int

The size of the column for variable-length types such as VarChar. Defaults to 0 (no size limit).

precision byte

The total number of significant digits for numeric types. Defaults to 0.

scale byte

The number of digits to the right of the decimal point for numeric types. Defaults to 0.

Returns

Column

The newly created Column with SchemaUpdate set to true.

Remarks

This overload is for schema migration where existing rows in the table need to be backfilled with a default value when the column is added. The existingRowValue is applied to all rows that exist at the time the column is created.

It automatically sets SchemaUpdate to true, which causes UpdateSchema(Schema, bool) to issue an ALTER TABLE ADD COLUMN statement with a backfill default for this column.

For defining columns as part of an initial schema deployment, use CreateColumn(string, DataType, bool, bool, int, byte, byte) instead.