Migrator
createMigration()
Signature
Section titled “Signature”createMigration() — returns string
Available in: migrator
Category: General Functions
Description
Section titled “Description”Creates a migration file. Whilst you can use this in your application, the recommended usage is via either the CLI or the provided GUI interface
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
migrationName | string | yes | — | |
templateName | string | no | — | |
migrationPrefix | string | no | timestamp |
Examples
Section titled “Examples”// 1. Create a blank migration file (uses timestamp prefix by default)
result = application.wheels.migrator.createMigration("CreateUsersTable");
// result -> "The migration 20240815123045_CreateUsersTable.cfc file was created"
// 2. Create a migration from a built-in template (e.g. create-table)
result = application.wheels.migrator.createMigration(
migrationName="CreatePostsTable",
templateName="create-table"
);
// 3. Create a migration using a sequential numeric prefix instead of a timestamp
result = application.wheels.migrator.createMigration(
migrationName="AddIndexToUsers",
migrationPrefix="numeric"
);
// result -> "The migration 001_AddIndexToUsers.cfc file was created"