Migration Generator
Usage
azu generate migration MIGRATION_NAME [attributes] [OPTIONS]Description
Options
Examples
Generate a migration with attributes
Generate a simple migration
Generate migration with foreign keys
Generate migration with various types
Generated Files
Migration File (src/db/migrations/TIMESTAMP_create_table_name.cr)
src/db/migrations/TIMESTAMP_create_table_name.cr)Migration Patterns
Create Table Migration
Add Column Migration
Create Index Migration
Create Table with Foreign Key
Create Join Table Migration
Column Types
Supported Column Types (CQL Schema DSL)
Generator Type
Crystal Type
Usage
CQL Schema DSL Syntax
Adding Indexes
Index Types
Single Column Indexes
Multi-Column Indexes
Partial Indexes
Running Migrations
Run All Migrations
Run Specific Number of Migrations
Migrate to Specific Version
Rollback Migrations
View Verbose Output
How Migrations Run
Best Practices
1. Use Descriptive Names
2. Keep Migrations Focused
3. Always Provide Rollback Logic
4. Use Data Types Appropriately
5. Add Indexes for Performance
Testing Migrations
Unit Testing
Integration Testing
Common Migration Patterns
1. Table Creation
2. Adding Foreign Keys
3. Data Migration
4. Schema Changes
Related Commands
Key Differences from Other ORMs
CQL vs ActiveRecord/Eloquent
Additional Resources
Last updated