Skip to content

Migrator

renameTable()

renameTable() — returns void

Available in: migration Category: Migration Functions

Used to change the name of an existing database table within a migration CFC. This is helpful when you want to standardize table names, correct naming mistakes, or improve clarity in your database schema. This operation preserves all the existing data, indexes, and constraints in the table while updating its name. Only available in a migration CFC.

NameTypeRequiredDefaultDescription
oldNamestringyesName the old table
newNamestringyesNew name for the table
1. Rename the users table
renameTable(oldName="users", newName="app_users");

2. Rename the orders table
renameTable(oldName="orders", newName="customer_orders");

3. Rename multiple tables in separate migration calls
renameTable(oldName="products_old", newName="products");
renameTable(oldName="temp_data", newName="archived_data");