SQL migrations for projects using PostgreSQL
Project description
pgmigrations
SQL migrations for projects using PostgreSQL
Example Usage
Initialise the migrations
pgmigrations init --dsn <dsn>
or
export PGMIGRATIONS_DSN=<dsn>
pgmigrations init
This will create a directory called migrations
in the current working directory
Create a migration
pgmigrations create --dsn <dsn> <tag>
or
export PGMIGRATIONS_DSN=<dsn>
pgmigrations create <tag>
This will create a skeleton migration in the migrations
directory. The migration will consist of a directory with
the name <timestamp>_migrations_<tag>
, for example 20200701_1030_migrations_first_migration
, which
contains two files; apply.sql
and rollback.sql
.
As the names suggests, apply.sql
will be executed when the migration is applied and rollback.sql
will be
executed if the migraiton is rollbacked.
Apply migrations
pgmigrations apply --dsn=<dsn> [--locations <comma separated list of migration locations>]
or
export PGMIGRATIONS_DSN=<dsn>
export PGMIGRATIONS_LOCATIONS=<comma separated list of migration locations>
pgmigrations apply
This will apply any unapplied migrations. Each migration is applied in an atomic transaction.
Rollback a migration
pgmigrations rollback --dsn=<dsn> [--locations <comma separated list of migration locations>]
or
export PGMIGRATIONS_DSN=<dsn>
export PGMIGRATIONS_LOCATIONS=<comma separated list of migration locations>
pgmigrations rollback <name>
This will rollback an already applied migration.
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
Hashes for pgmigrations-0.0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12ba0a6a8a3c460eec382e414f385874def41c964e1ee7b3575e9e16be1eeca9 |
|
MD5 | fe387f9d1cce7d39bd8b00ef6aaa06ef |
|
BLAKE2b-256 | 1c38e6886e344c93f506ba9c870509b6da6cc0fdb5d744bc926b66cd8a0b6a5e |