Migrator
Migrator
addColumn()— Adds a new column to an existing table.addForeignKey()— Adds a foreign key constraint between two tables. This ensures that values in one table’s column must exist in the referaddIndex()— Adds a database index on one or more columns of a table. Indexes speed up queries that filter, sort, or join on those coaddRecord()— Inserts a new record into a table. This function is only available inside a migration CFC and is part of the Wheels migraddReference()— Adds a reference column and a foreign key constraint to a table in one step. This is a shortcut for creating an integerbigInteger()— Adds one or more big integer columns to a table definition in a migration. Use this when you need columns capable of stobinary()— Adds one or more binary columns to a table definition in a migration. Use this for storing raw binary data, such as fileboolean()— Adds one or more boolean columns to a table definition in a migration. Use this for columns that store true/false valueschange()— Used in migrations to alter an existing table in the database. This function allows you to modify the structure of a tabchangeColumn()— Changes the definition of an existing column in a database table. This function is used in migration CFCs to update coluchangeTable()— Creates a table definition object used to store and apply modifications to an existing table in the database. This functchar()— Adds one or more CHAR columns to a table definition in a migration. Use this function to define fixed-length string colucolumn()— Adds a column to a table definition in a migration. This function is used when defining or altering database tables. Itcreate()— The create() method is used to create a database table based on the table definition that has been built using the migracreateMigration()— The createMigration() method is used to generate a new migration file for managing database schema changes. While you cacreateTable()— The createTable() function is used in migration CFCs to define a new database table. It returns a TableDefinition objectcreateView()— The createView() function is used in migration CFCs to define a new database view. It returns a ViewDefinition object, odate()— date() is a table definition function used in a migration CFC to add one or more DATE columns to a table.datetime()— Adds datetime columns to a table definition when creating or altering a table in a migration. These columns store both ddecimal()— Adds decimal (numeric) columns to a table definition when creating or altering tables via a migration CFC.down()— down() defines the steps to revert a database migration. It’s executed when rolling back a migration, typically to undodropForeignKey()— dropForeignKey() is used to remove a foreign key constraint from a table in the database. This is typically done duringdropReference()— dropReference() is used to remove a foreign key constraint from a table in the database using the reference name that wadropTable()— dropTable() is used to remove a table from the database entirely. This is a destructive operation, so all data in the tadropView()— dropView() is used to remove a database view entirely. A view is a saved query that acts like a virtual table, so this oexecute()— execute() allows you to run a raw SQL query directly from a migration file. This is useful when you need to perform operfloat()— The float() function is used in a table definition during a migration to add one or more float-type columns to a databasgetAvailableMigrations()— The getAvailableMigrations() function scans the migration folder (by default /app/migrator/migrations/) and returns an agetCurrentMigrationVersion()— The getCurrentMigrationVersion() function returns the version number of the latest migration that has been applied to thinteger()— Adds one or more integer columns to a table definition during a migration. You can optionally specify a limit, default vmigrateTo()— Migrates the database schema to a specified version. This function is primarily intended for programmatic database migramigrateToLatest()— Migrates the database schema to the latest available migration version. This is a shortcut for migrateTo(version) withouprimaryKey()— Used inside migration table definitions to define a primary key for the table. By default, it creates a single-column inredoMigration()— Allows you to rerun a specific database migration version. This can be useful for testing migrations, correcting issuesreferences()— Used when defining a table schema to add reference columns that act as foreign keys, linking the table to other tables iremoveColumn()— Used to delete a column from a database table within a migration CFC. This is useful when you need to remove obsolete orremoveIndex()— Used to delete an index from a database table within a migration CFC. Indexes are typically added to improve query perforemoveRecord()— Used to delete specific records from a database table within a migration CFC. This is useful when you need to clean up orenameColumn()— Used to change the name of an existing column in a database table within a migration CFC. This is useful when you need trenameTable()— Used to change the name of an existing database table within a migration CFC. This is helpful when you want to standardistring()— Used to add one or more string (VARCHAR) columns to a database table. It supports specifying default values, nullabilitytext()— Used within a migration to add one or more text columns to a database table definition. Text columns are designed for sttime()— Adds one or more TIME columns to a table definition in a migration. Only available in a migrator CFC.timestamp()— Used to add one or moreTIMESTAMP(orDATETIME) columns to a table definition. It lets you spetimestamps()— Shortcut for adding Wheels’ convention-based automatic timestamp and soft delete columns to a table definition during miuniqueidentifier()— Used to add one or more UUID (Universally Unique Identifier) columns to a table definition. These columns are useful forup()— Defines the actions to migrate your database schema forward. It is called when applying a migration and is typically paiupdateRecord()— Allows you to update an existing record in a database table directly from within a migration CFC. This function is parti