Migration DSL
Migration Class
class CreateUsers < CQL::Migration(20250125001401)
def up
# Apply changes
end
def down
# Rollback changes
end
endCreating Tables
schema.table
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
column :active, Bool, default: true
timestamps
index [:email], unique: true
end
schema.users.create!
end
def down
schema.users.drop!
end
endColumn Methods
primary
column
Option
Type
Description
Type-Specific Column Methods
Supported Types
Crystal Type
SQL Type
timestamps
Index Methods
index
create_index / drop_index
Foreign Key Methods
foreign_key
Parameter
Type
Description
Composite Foreign Keys
Altering Tables
schema.alter
Alter Operations
Method
Description
Alter Examples
Complete Example
Migration Execution
See Also
Last updated
Was this helpful?