generic migration provider
Project description
Trek is a simple tool to do migrations of whatever you’d like. It has terrible documentation because it’s pre-1.0.
Usage
Install! pip install trek
Now say you have a directory of migrations:
migrations ├── 1.sql ├── 2.sql └── 3.sql
Where each of these looks a bit like this:
-- MIGRATE UP CREATE TABLE test ( id INTEGER PRIMARY KEY ); -- MIGRATE DOWN DROP TABLE test;
(using any comment character, but lines with MIGRATE UP and MIGRATE DOWN will be excluded and only one of each line is expected. Also note that to simplify this example the numbers have been used, but you should probably use timestamps like 2014-01-01T00-00-00_human_name.sql)
You can then run:
trek --runner=postgres up postgres://trek_test@localhost/trek_test
And the migrations will be run for you. Magic!
Writing your own runner
A runner is just a Python object with version, up, and down methods. version will be called with no arguments to determine the current version, while up and down will be called with a name (string) and Migration object (which has string up and down members). up and down should be generators, and you can yield as many messages as you need to so that the user knows what’s going on.
After you put your migrator in a file, specify it with python.path.to.module:MigratorName. For example, the postgres migrator is expanded by the CLI interface but it’s full path is trek.runners.postgres:PostgresRunner
TODO
✓ release on PyPI
✓ add Postgres migrator
add other migrators as needed (open an issue on Github, for what you want, please!)
add flask-script manager interface
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file trek-0.0.1-.tar.gz
.
File metadata
- Download URL: trek-0.0.1-.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e6ce92723cf7c6b276b9cc53d79fe271e958c0a4e1c7e95649b214fb8b23967 |
|
MD5 | cc8ec636603784055488ea6d93007c60 |
|
BLAKE2b-256 | 670d1acf67b1f7378ca72bc129c029bdf1874e6522e223396cfdc58f5d981e72 |
File details
Details for the file trek-0.0.1_-py2-none-any.whl
.
File metadata
- Download URL: trek-0.0.1_-py2-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags:
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6977629f4eac4aa6fd8edcb08955af86207125dfc2f1a9b072e8936cc69bfeb9 |
|
MD5 | 1a7279803849e1f66bcb13ffe2ac3209 |
|
BLAKE2b-256 | f438b960a0288b41b857ed83f6e80d8f8d2c4fb876e5a8594f4a42715cf0b037 |