A CLI for managing postgres DB migrations
Project description
lonny_common_pg_migrate
A CLI for managing postgres DB migrations.
Installation
pip install lonny_common_pg_migrate
Usage
First, we must create a MigrationRunner
object. We can do this like:
from lonny_common_pg_migrate import MigrationRunner
# Get a 'lonny_common_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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 590709eddad0454403142a06f62fbd2fed3d280b055eac3c2ca5416663f2c72d |
|
MD5 | db1c181abaf70b0d6548cbde28ce1cb9 |
|
BLAKE2b-256 | f24bf91d39c68f06aef74e8401a1448e4b19ed19f470e1dcefabfc8662cc865a |
Close
Hashes for lonny_common_pg_migrate-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fdf851ffc9025d8745a0c2fef6d2e7e41b955d5753ee9f13879cae441d78cec |
|
MD5 | 24117bab6673b56d708719420394b25c |
|
BLAKE2b-256 | 0f33cc9624566999eeb1fdc90e76b98acf04b2419278f360d44f35e1176ec9e6 |