Skip to content

Migrator

removeColumn()

removeColumn() — returns void

Available in: migration Category: Migration Functions

Used to delete a column from a database table within a migration CFC. This is useful when you need to remove obsolete or incorrectly added columns during schema evolution. Optionally, you can also remove a reference column by specifying its referenceName. Only available in a migration CFC.

NameTypeRequiredDefaultDescription
tablestringyesThe table containing the column to remove
columnNamestringnoThe column name to remove
referenceNamestringnooptional reference name
1. Remove a single column from a table
removeColumn(table="users", columnName="middleName");

2. Remove a foreign key reference column
removeColumn(table="orders", referenceName="customerId");

3. Remove multiple columns in separate calls
removeColumn(table="products", columnName="oldPrice");
removeColumn(table="products", columnName="discountRate");