A CLI for managing postgres DB migrations
Project description
lonny_pg_migrate
A CLI for managing postgres DB migrations.
Installation
pip install lonny_pg_migrate
Usage
First, we must create a MigrationRunner
object. We can do this like:
from lonny_pg_migrate import MigrationRunner
# Get a 'lonny_pg' DB connection.
db = get_lonny_pg_connection()
runner = MigrationRunner(db)
To define a migration, we can simply now do:
# N.B. sort_key is optional and defaults to the slug.
@runner.migrate("migration_0", sort_key = "0")
def migration_0(db):
do_some_action(db)
To perform the migration, we can either invoke the runner directly using:
# This will wipe the database
runner.drop()
# This will run - in order of sort_key, all migrations which haven't yet run.
runner.migrate()
Or via the CLI using:
pg_migrate path.to.module:runner_var
As above, drop
functionality is supported by passing in a --drop
argument.
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
Close
Hashes for lonny_common_pg_migrate-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce7f859657d2ce2e93fb3d7106bba3d0b82763cba6952c5b410d872951404690 |
|
MD5 | a09a6be57b3637a4614abf4422981144 |
|
BLAKE2b-256 | 02fe30ddcd024ff0f3d0b60d0291c913ca0d0a86961328163beb9b104102f183 |
Close
Hashes for lonny_common_pg_migrate-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69a28ccd45cf82406ef7304ebbeed748d783d4687fb8de1746e8fbc9018172dc |
|
MD5 | c271667bc523af880cb759e64b4aaaab |
|
BLAKE2b-256 | 3cdfddb55275ecdc957c18bbca8101fda1b4ea1a8ab9034a29175b780b04fd75 |