A relational database migration tool, written in Crystal. It uses the cql framework.
migro currently only supports YAML migrations of the form
metadata: version: 0.1 changes: - # ... up: - # ...
metadata.version is optional, but if present, then
migro will validate that it supports the given YAML migration version (currently, only
0.1 is allowed).
up: are arrays of Migration Commands.
changes: are meant to hold migration commands that can be automatically rolled back. Currently, only
create_table is allowed.
up: are meant to hold migration commands that will only be applied when migrating ‘up’ or forward.
- Automatic rollback for commands in
migro currently only supports three migration commands:
create_table command takes the form:
- create_table: name: table_name columns: - # ...
Where each column has the following fields:
|primary||boolean||specifies the column is a
insert command takes the form:
- insert: table: table_name rows: - column1: value column2: 123
Which is equivalent to the SQL:
INSERT INTO table_name (column1, column2) VALUES ("value", 123);
sql command takes in ‘raw’ SQL:
- sql: ALTER TABLE params ADD CONSTRAINT params_unique_code_and_name UNIQUE (code, name);
The given SQL is executed ‘as is’.