Migrator
removeColumn()
Signature
Section titled “Signature”removeColumn() — returns void
Available in: migration
Category: Migration Functions
Description
Section titled “Description”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.
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 |
referenceName | string | no | — | optional reference name |
Examples
Section titled “Examples”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");