A postgres (cockroach) migration tool. This is still alpha grade software.
Basis a config file (sample) it guides one through the process of running migrations for a database.
A default table called schema_migrations
is created in the database configured. This
table keeps track of the migrations run so far.
./architect --config=<path to config> -w
The -w
option above is required to run in wizard mode. One can also choose to run the binary
using the command line args directly for explicit behaviour. Run
./architect --help
for available options.
Please note that the this binary generates migration files for you and it will only work with the
naming convention ( timestamp_(up|down).sql
) of these generated files. While you can generate
these files yourself it is highly recommended that you don't. Please use the --new
command line
option or the --wizard
mode to generate new migrations.
There are two bits of configuration to keep in mind:
path to a .toml config file detailing connection to the database migrations will be run on.
path to the directory where the migration files reside. Please note that this is a
parent directory. Basis the app
option provided in the config file a sub directory
is created which will contain all generated migration files. Defaults to ./migrations
a new version of migration files are generated. One for up
[timestamp]_up.sql
and one for down [timestamp]_down.sql
Migrate up N
times or till the end of the remaining migration versions whichever happens eralier.
Migrate up all remaining versions.
Migrate down N
times or till the beginnning of migration versions whichever happens earlier.
Migrate down till the beginning of migrations. Be very sure this is what you want to run.
A wizard takes over and guides you through the migration experience.
Prints help info
Prints version info
This is provided by a .toml
file using the --config
option of the executable.
The name of the app for which this migration is being run. The
The name of the database to connect to
The sql server host
The sql server port. Default: 5432
The user name to authenticate with
The password to authenticate with
Whether the connection should use tls
Path of the root certificate to be used in case ssl
is true. When not provided the env
variable PGSSLROOTCERT
, if set, is used. If the env variable is not set either it falls back
to ~/.postgresql/root.crt
.
Maximum time to wait when establishing connection with databse server. Default of 0 will make it wait indefinitely.
cargo build --release
To be able to run the tests a connection config file is required. A sample is available at extras/test_config.toml. Once it's configured for a working database run
ARCHITECT_TEST_CONFIG="./extras/test_config.toml" cargo test -- --nocapture
The current set of tests are very basic, checking for success cases only.