Skip to content

Migrator

removeColumn()

removeColumn() — returns void

Available in: migration Category: Migration Functions

Removes a column from a database table Only available in a migration CFC

NameTypeRequiredDefaultDescription
tablestringyes—The table containing the column to remove
columnNamestringno—The column name to remove
columnNamesstringno—Modern alias for columnName (matches the plural form every TableDefinition column helper accepts). Pass one or the other — not both.
referenceNamestringno—optional reference name
// 1. Remove a column by specifying its name directly
removeColumn(table="members", columnName="status");

// 2. Remove a reference column using its reference name (removes the <referenceName>id column)
removeColumn(table="posts", referenceName="author");
// Removes the column named "authorid" from the posts table

// 3. Typical use inside a migration's down() method to reverse an addColumn()
function down() {
    removeColumn(table="products", columnName="discountPrice");
}