Skip to main content

Generate migrations between Postgres databases

Project description

image image image

Generate migrations between Postgres databases.

Installation

pip install pgmig

Usage

Structure migration

Get the SQL that, when applied to source, makes its structure (tables, extensions, and other object definitions) match target:

import pgmig

sql = pgmig.generate(
    source="postgresql://user:pass@localhost:5432/current",
    target="postgresql://user:pass@localhost:5432/desired",
)

print(sql)  # the migration SQL — run it yourself against `source`

When the two structures already match, generate returns an empty string. pgmig opens read-only connections to both databases and never runs the generated SQL for you.

Contributing

To contribute simply open a PR with your changes, or an issue with your bug/request.

All checks (Linters, type checks and tests) automatically run in CI through GitHub Actions.

Running checks locally

Local development is done with uv.

Start by installing all the development dependencies:

uv sync

To run the linters use pre-commit:

pre-commit run -a

To run the unit tests use pytest:

pytest -c tests/pytest.ini tests

To run type checks use mypy or ty (both are run in CI):

mypy --config-file linters/mypy.toml src tests
ty check --config-file linters/ty.toml src tests

Releasing

To release a new version, run the interactive script:

./scripts/release.py

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

pgmig-0.0.3.tar.gz (567.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pgmig-0.0.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file pgmig-0.0.3.tar.gz.

File metadata

  • Download URL: pgmig-0.0.3.tar.gz
  • Upload date:
  • Size: 567.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pgmig-0.0.3.tar.gz
Algorithm Hash digest
SHA256 3df51f3767dfb5af12bcf487aab9407c0784070aa8c02097b860e1ce4c350705
MD5 e62cf52609eaddc97b5c89fcda37d08c
BLAKE2b-256 8b33177ea8357ce0976daca7c2f7ac0708bab43f819356fb23e3fca4af68e89e

See more details on using hashes here.

File details

Details for the file pgmig-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pgmig-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pgmig-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 93b57a058fc5a65c9900e6ecc0b790d5400d3bcc18ee640f375bb3a1143c2901
MD5 faec5de9572df8d28a4bc009608ffea7
BLAKE2b-256 f7a7e55930d3a9724928bbe162767f12945e0852d426e9d6bbf3af14dcd54bc0

See more details on using hashes here.

Supported by

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