Migrator
renameColumn()
Signature
Section titled “Signature”renameColumn() — returns void
Available in: migration
Category: Migration Functions
Description
Section titled “Description”Renames a table column 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="username");
// 2. Rename a column as part of a migration's up() and down() methods
component extends="wheels.migrator.Migration" hint="Rename fullName to displayName in profiles" {
function up() {
renameColumn(table="profiles", columnName="fullName", newColumnName="displayName");
}
function down() {
renameColumn(table="profiles", columnName="displayName", newColumnName="fullName");
}
}