Create a Migration
Migration File Structure
migrations/
├── 001_create_users.cr
├── 002_create_posts.cr
└── 003_add_email_index.crBasic Migration
# migrations/001_create_users.cr
class CreateUsers < CQL::Migration(1)
def up
schema.table :users do
primary :id, Int64, auto_increment: true
column :name, String, null: false
column :email, String, null: false
timestamps
end
schema.users.create!
end
def down
schema.users.drop!
end
endMigration Number
Create Table
Add Columns
Add Index
Add Foreign Key
Rename Column
Change Column Type
Irreversible Migration
Verify Migration
Related
Last updated
Was this helpful?