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>

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> <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>

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

Rollback a migration

pgmigrations rollback <dsn> <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.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

pgmigrations-0.0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pgmigrations-0.0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 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.1.0.tar.gz
Algorithm Hash digest
SHA256 f80daab3f134fcca3947e62a9d77d0582faebf841f5b2138c59a69e92c5668a8
MD5 912abdf91cec2ea04d0b73a40c424bff
BLAKE2b-256 f5ec0476d7bb917ac9ab1fb9cac59fd85849d4471bb77f97bde8266e036149b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pgmigrations-0.0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44f404f09636717eac0873a581daf32bd20f20b7e857917a4e6c66870eed0574
MD5 c802b65e920d9240f532f2fd2a3f93b3
BLAKE2b-256 bde448993da4f36d43e7894c0ca10b6d3f2467167c5c63c1d08d97debf2151dc

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