Migrator
renameColumn()
Signature
Section titled “Signature”renameColumn() — returns void
Available in: migration
Category: Migration Functions
Description
Section titled “Description”Used to change the name of an existing column in a database table within a migration CFC. This is useful when you need to standardize column names, correct naming mistakes, or improve clarity in your database schema. Renaming a column preserves the existing data and column type while updating the schema. Only available in a migration CFC.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
table | string | yes | — | The table containing the column to rename |
columnName | string | yes | — | The column name to rename |
newColumnName | string | yes | — | The new column name |
Examples
Section titled “Examples”1. Rename a column in the users table
renameColumn(table="users", columnName="username", newColumnName="user_name");
2. Rename a column in the orders table
renameColumn(table="orders", columnName="createdAt", newColumnName="order_created_at");
3. Rename multiple columns in separate migration calls
renameColumn(table="products", columnName="oldPrice", newColumnName="price_old");
renameColumn(table="products", columnName="discountRate", newColumnName="discount_percent");