Database.Migration
Database
Ordered schema-evolution plans (rename, type change, raw SQL).
Reconcile never auto-DROPs columns; remove them with sql (or rename via renameColumn) in a plan under src/migrations/.
sql and alterColumnTypeUsing splice author string literals into DDL. Treat them like checked-in migrations: privileged author input, never request-controlled data.
Types
Plan
type Plan = PlanAn ordered migration plan applied before models reconcile.
Examples
plan : Plan
plan =
Migration.id "20261031_rename_todo_title"
|> Migration.renameColumn "todos" "title" "label"Values
id
id : String -> PlanStart a migration plan with a stable id recorded in selm_migrations.
Examples
Migration.id "20261031_rename_todo_title"renameColumn
renameColumn : String -> String -> String -> Plan -> PlanRename a column before models reconcile.
Examples
Migration.id "20261031_rename_todo_title"
|> Migration.renameColumn "todos" "title" "label"renameTable
renameTable : String -> String -> Plan -> PlanRename a table before models reconcile.
Examples
Migration.id "20261031_rename_drafts"
|> Migration.renameTable "drafts" "articles"alterColumnType
alterColumnType : String -> String -> String -> Plan -> PlanChange a column SQL type (table, column, type).
Examples
Migration.id "20261031_widen_priority"
|> Migration.alterColumnType "todos" "priority" "bigint"alterColumnTypeUsing
alterColumnTypeUsing : String -> String -> String -> String -> Plan -> PlanChange a column type with an explicit USING expression.
The USING expression is spliced into DDL; it must be a single expression (no ;, --, or /*). Prefer checked-in literals, not request data.
Examples
Migration.id "20261031_cast_score"
|> Migration.alterColumnTypeUsing "scores" "value" "integer" "value::integer"sql
sql : String -> Plan -> PlanEscape hatch: run raw SQL (split on ';'). Use for DROP COLUMN and other irreversible edits.
Privileged author DDL — same trust as other checked-in migration plans, not request-controlled input.
Examples
Migration.id "20261031_drop_legacy"
|> Migration.sql "ALTER TABLE todos DROP COLUMN legacy_flag"