migrations for the masses
With leiningen:
git clone https://github.com/it0a/seql && \
cd seql && \
lein bin
Will output a binary at target/seql (Add this to your PATH)
seql currently runs under the following heirarchy:
seql
migrations/migrations.clj
migrations/databases.clj
migrations/migrations.clj:
[["0.0.1" ["1.sql"
"2.sql"]]
["0.0.2" ["1.sql"]]]
This defines three files that will run in the following order:
migrations/0.0.1/1.sql
migrations/0.0.1/2.sql
migrations/0.0.2/1.sql
migrations/databases.clj:
{"default" {:classname "com.mysql.jdbc.Driver"
:subprotocol "mysql"
:user "root"
:password "rootpass"
:host "0.0.0.0"
:port "3306"
:databases [{:schema "example"}
{:schema "example2"}
{:schema "example3"}
{:schema "example4"}
{:schema "example5"}]}
"another" {:classname "com.mysql.jdbc.Driver"
:subprotocol "mysql"
:user "root"
:password "rootpass"
:host "0.0.0.0"
:port "3306"
:databases [{:schema "example6"
:user "anotheruser"
:password "anotherpassword"}
{:schema "example7"}
{:schema "example8"}
{:schema "example9"}
{:schema "example10"}]}}
Note that :schema "example6"
will connect with :user "anotheruser"
and :password "anotherpassword"
. All other :schema
will connect with :user "root"
and :password "rootpass"
.
seql [db-groups...]
Using the above databases.clj:
seql default another
Will run migrations on all databases in the 'default' and 'another' groups.
To synchronize all migrations as having been run:
seql --sync [db-groups...]
NOTE: Doing this will also sync migrations with checksum mismatches that have already been run.
TODO: --sync --file "filename"
TODO: --remove --file "filename" [db-groups]
- --dry-run
- Rollback migrations
- Error handling
- Leiningen plugin
See the project wiki for more details.
Copyright © 2015 it0a
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.