Migrator
removeColumn()
Signature
Section titled “Signature”removeColumn() — returns void
Available in: migration
Category: Migration Functions
Description
Section titled “Description”Removes a column from a database table Only available in a migration CFC
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
table | string | yes | — | The table containing the column to remove |
columnName | string | no | — | The column name to remove |
columnNames | string | no | — | Modern alias for columnName (matches the plural form every TableDefinition column helper accepts). Pass one or the other — not both. |
referenceName | string | no | — | optional reference name |
Examples
Section titled “Examples”// 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");
}