wheels dbmigrate create blank
Create an empty database migration file with up and down methods.
Synopsis
Description
The dbmigrate create blank
command generates a new empty migration file with the basic structure including up()
and down()
methods. This provides a starting point for custom migrations where you need full control over the migration logic.
Options
--name
--name
Type: String
Required: Yes
Description: The name of the migration (will be prefixed with timestamp)
--datasource
--datasource
Type: String
Default: Application default
Description: Specify the datasource this migration targets
--description
--description
Type: String
Default: Empty
Description: Add a description comment to the migration file
--template
--template
Type: String
Default:
blank
Description: Use a custom template for the migration
Examples
Create a basic empty migration
Create migration with description
Create migration for specific datasource
Generated File Structure
The command creates a file named YYYYMMDDHHmmss_<name>.cfc
with the following structure:
Use Cases
Custom Database Operations
For complex operations not covered by other generators:
Data Migrations
When you need to migrate data, not just schema:
Multi-Step Operations
For migrations requiring multiple coordinated changes:
Database-Specific Features
For database-specific features not abstracted by CFWheels:
Best Practices
1. Descriptive Names
Use clear, descriptive names that indicate the migration's purpose:
2. Implement Both Methods
Always implement both up() and down() methods:
3. Use Transactions
Wrap operations in transactions for atomicity:
4. Add Comments
Document complex operations:
Available Migration Methods
Within your blank migration, you can use these helper methods:
createTable(name, options)
- Create a new tabledropTable(name)
- Drop a tableaddColumn(table, column, type, options)
- Add a columnremoveColumn(table, column)
- Remove a columnchangeColumn(table, column, type, options)
- Modify a columnaddIndex(table, column, options)
- Add an indexremoveIndex(table, column)
- Remove an indexexecute(sql)
- Execute raw SQLannounce(message)
- Output a message during migration
Notes
Migration files are created in
/db/migrate/
or your configured migration pathThe timestamp ensures migrations run in the correct order
Always test migrations in development before production
Keep migrations focused on a single purpose
Related Commands
Last updated
Was this helpful?