Skip to content

Migrator

renameColumn()

renameColumn() — returns void

Available in: migration Category: Migration Functions

Renames a table column Only available in a migration CFC

NameTypeRequiredDefaultDescription
tablestringyes—The table containing the column to rename
columnNamestringyes—The column name to rename
newColumnNamestringyes—The new column name
// 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");
    }
}