Metadata-Version: 2.4
Name: alembic-utils-extended
Version: 1.1.2
Summary: A sqlalchemy/alembic extension for migrating entities like functions, triggers, views, materialized views, and check constraints.
License-Expression: MIT
License-File: LICENSE
Author: Justin Malin
Author-email: justin@joincandidhealth.com
Requires-Python: >=3.10
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: SQL
Requires-Dist: alembic (>=1.9)
Requires-Dist: flupy
Requires-Dist: parse (>=1.8.4)
Requires-Dist: sqlalchemy (>=1.4)
Requires-Dist: typing_extensions (>=0.1.0)
Project-URL: GitHub, https://github.com/candidhealth/alembic-utils-extended
Project-URL: PyPI, https://pypi.org/project/alembic-utils/
Description-Content-Type: text/markdown

# Alembic Utils Extended

<p>
    <a href="https://github.com/candidhealth/alembic-utils-extended/actions">
        <img src="https://github.com/candidhealth/alembic-utils-extended/workflows/Tests/badge.svg" alt="Test Status" height="18">
    </a>
    <a href="https://github.com/candidhealth/alembic-utils-extended/actions">
        <img src="https://github.com/candidhealth/alembic-utils-extended/workflows/pre-commit%20hooks/badge.svg" alt="Pre-commit Status" height="18">
    </a>
</p>
<p>
    <a href="https://github.com/candidhealth/alembic-utils-extended/blob/master/LICENSE"><img src="https://img.shields.io/pypi/l/markdown-subtemplate.svg" alt="License" height="18"></a>
    <a href="https://badge.fury.io/py/alembic-utils-extended"><img src="https://badge.fury.io/py/alembic-utils-extended.svg" alt="PyPI version" height="18"></a>
    <a href="https://github.com/psf/black">
        <img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Codestyle Black" height="18">
    </a>
    <a href="https://pypi.org/project/alembic-utils-extended/"><img src="https://img.shields.io/pypi/dm/alembic-utils-extended.svg" alt="Download count" height="18"></a>
</p>
<p>
    <a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python version" height="18"></a>
    <a href=""><img src="https://img.shields.io/badge/postgresql-11+-blue.svg" alt="PostgreSQL version" height="18"></a>
</p>

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

This is a fork of the much more popular [alembic_utils](https://github.com/olirice/alembic_utils) package
to extend the capabilities of [Alembic](https://alembic.sqlalchemy.org/en/latest/), which adds support for
autogenerating a larger number of [PostgreSQL](https://www.postgresql.org/) entity types,
including [functions](https://www.postgresql.org/docs/current/sql-createfunction.html), [views](https://www.postgresql.org/docs/current/sql-createview.html), [materialized views](https://www.postgresql.org/docs/current/sql-creatematerializedview.html), [triggers](https://www.postgresql.org/docs/current/sql-createtrigger.html),
and
[policies](https://www.postgresql.org/docs/current/sql-createpolicy.html).

This repo adds additional support for defining indices for materialized views and
autogenerating [check constraints](https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-CHECK-CONSTRAINTS).

## Quickstart

Visit the [quickstart guide](docs/quickstart.md) for usage instructions.

### Entity Registration

```python
# 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`:

```python
# 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.

```shell
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](https://github.com/olirice/alembic_utils), so it's possible something is
misconfigured.

### Testing

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

