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

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

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.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

pgmigrations-0.0.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pgmigrations-0.0.2.tar.gz
  • Upload date:
  • Size: 3.9 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.2.tar.gz
Algorithm Hash digest
SHA256 5b4054ef198c489ca16404c730837952ce2e7c9599a5ede2a0eba20489907011
MD5 b275f17eb140a368e4a8c847b96d21f2
BLAKE2b-256 027f52d9c6f897d3d03215018bb88137aa7d561f899a5b9a90ee220d36dea09c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pgmigrations-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d783351b27d50115eccc763b98611d0e5949c4fdbbd7603f75541122d72e325a
MD5 a223dbc8d86f83948571c3d17099694e
BLAKE2b-256 7ae072dbf6033cf79974abb18d74916b90e03faf86a7368e4dbd69d8be83dc37

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