Migrator
renameTable()
Signature
Section titled “Signature”renameTable() — returns void
Available in: migration
Category: Migration Functions
Description
Section titled “Description”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.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
oldName | string | yes | — | Name the old table |
newName | string | yes | — | New name for the table |
Examples
Section titled “Examples”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");