Skip to main content

A sqlalchemy/alembic extension for migrating entities like functions, triggers, views, materialized views, and check constraints.

Project description

Alembic Utils Extended

Test Status Pre-commit Status

License PyPI version Codestyle Black Download count

Python version PostgreSQL version

Autogenerate Support for PostgreSQL Functions, Views, Materialized Views, Triggers, Policies, and Check Constraints

This is a fork of the much more popular alembic_utils package to extend the capabilities of Alembic, which adds support for autogenerating a larger number of PostgreSQL entity types, including functions, views, materialized views, triggers, and policies.

This repo adds additional support for defining indices for materialized views and autogenerating check constraints.

Quickstart

Visit the quickstart guide for usage instructions.

Entity Registration

# migrations/env.py

from alembic_utils_extended.pg_view import PGView
from alembic_utils_extended.replaceable_entity import register_entities

view = PGView(schema="public", signature="view", definition="SELECT 1")
register_entities([view])

Monitor Check Constraints

Check constraints defined in SQLAlchemy models can also be autogenerated. Note that check constraints must be named. Add to your env.py:

# migrations/env.py
from alembic import context

context.configure(
    # ... other configurations ...
    compare_check_constraints=True,
)

Autogeneration

The next time you autogenerate a revision, Alembic will detect if your entities are new, updated, or removed and populate the migration script.

alembic revision --autogenerate -m 'message'

Contributing

If you have any issues with contributing, please reach out to justin@joincandidhealth.com so that we can work out any issues you are having! This is mostly just forked directly from alembic_utils, so it's possible something is misconfigured.

Testing

poetry install
poetry run pre-commit run --all-files
poetry run pytest

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

alembic_utils_extended-1.1.2.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

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

alembic_utils_extended-1.1.2-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file alembic_utils_extended-1.1.2.tar.gz.

File metadata

  • Download URL: alembic_utils_extended-1.1.2.tar.gz
  • Upload date:
  • Size: 23.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for alembic_utils_extended-1.1.2.tar.gz
Algorithm Hash digest
SHA256 44d593a90cc11a258af4f0db94c606c907e75482f8908d9cd01d7542a1ba0974
MD5 12b6448feb48af37395ad9de40697275
BLAKE2b-256 fe3125915108167bbad7664e11987d337e180f049349b5a976aa0d3fa0f9a220

See more details on using hashes here.

Provenance

The following attestation bundles were made for alembic_utils_extended-1.1.2.tar.gz:

Publisher: publish.yml on candidhealth/alembic-utils-extended

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alembic_utils_extended-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for alembic_utils_extended-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 06104ad183bdabedfcb7ee9246447b6b766e71f6f3d716ddb39a34ac4cb07b65
MD5 135f054d05c3b59a06f449fa47b6045e
BLAKE2b-256 fb2c8ab2aa93b842c37ec4f42c1725ab82fff53ea2c101668bcb19d03485b96d

See more details on using hashes here.

Provenance

The following attestation bundles were made for alembic_utils_extended-1.1.2-py3-none-any.whl:

Publisher: publish.yml on candidhealth/alembic-utils-extended

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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