Skip to content

Latest commit

 

History

History
114 lines (87 loc) · 2.52 KB

README.md

File metadata and controls

114 lines (87 loc) · 2.52 KB

seql

migrations for the masses

Build

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)

Configuration

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".

Usage

Running Migrations

seql [db-groups...]

Using the above databases.clj:

seql default another

Will run migrations on all databases in the 'default' and 'another' groups.

Synchronizing Migrations

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"

Removing Migrations

TODO: --remove --file "filename" [db-groups]

TODO

  • --dry-run
  • Rollback migrations
  • Error handling
  • Leiningen plugin

Wiki

See the project wiki for more details.

License

Copyright © 2015 it0a

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.