Skip to main content

SQL migrations for projects using PostgreSQL

Project description

pgmigrations

Build Status Coverage Status Code style: black

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 and will create a table called pgmigrations in the database to store the migration history.

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>_tag, for example 20200701_1030_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>

or

export PGMIGRATIONS_DSN=<dsn>
pgmigrations apply

This will apply any unapplied migrations. Each migration is applied in an atomic transaction.

Rollback a migration

pgmigrations rollback --dsn=<dsn> <name> 

or

export PGMIGRATIONS_DSN=<dsn>
pgmigrations rollback <name>

This will rollback an already applied migration.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pgmigrations-0.0.4.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

pgmigrations-0.0.4-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file pgmigrations-0.0.4.tar.gz.

File metadata

  • Download URL: pgmigrations-0.0.4.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.7

File hashes

Hashes for pgmigrations-0.0.4.tar.gz
Algorithm Hash digest
SHA256 35e623833ab72cf0da6594ebce502c27572d1f2afddc4202856ff1f7744f5450
MD5 74229d20300b7f2135d723106fec01f8
BLAKE2b-256 0aaa4dee12458ceed8c041589040a20027119b8b5d26e1cbb79e4d31c76013f4

See more details on using hashes here.

File details

Details for the file pgmigrations-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pgmigrations-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.7

File hashes

Hashes for pgmigrations-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 796421824a8141d3dcc94130efb9c3ad7931902aa0c05c85dad22ebb209e29b1
MD5 143a5fdb6511290e46bd3c7f2f43b653
BLAKE2b-256 38f24241ecc04c62521b2edf9feec90e58910f7f447773353192b663a77d9f53

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page