Skip to main content

This takes a sqlalchemy schema and applies alembic migrations.

It's used by the ent framework on top of alembic autogenerate to ensure that all supported schema types are automatically handled.

Will beef up this README eventually and add examples later.

Called as follows: python3 auto_schema -s={pathToSchema} -e={engineURL}.

Only supports Postgres DB at the moment.

Concurrent indexes

auto_schema renders CREATE INDEX CONCURRENTLY when the SQLAlchemy index uses postgresql_concurrently=True. This is surfaced in ent via indices: [{ ..., concurrently: true }] or field-level indexConcurrently: true for index: true.

Notes:

  • Concurrent index ops are wrapped in autocommit_block() in generated Alembic revisions.
  • Drops are only concurrent if the generated op explicitly includes postgresql_concurrently=True (it cannot be inferred for removed indexes).

Design notes and tradeoffs:

  • We do not default to concurrent drops. DROP INDEX CONCURRENTLY is Postgres-specific and must run outside a transaction; defaulting it everywhere would be surprising and would break non-Postgres use.
  • We cannot infer whether an existing index was created concurrently once it is removed from schema. Postgres does not store that metadata, and Alembic's diff only yields a DropIndexOp without the flag.
  • Alembic can render postgresql_concurrently=True, but it does not automatically wrap it in autocommit_block(). To guarantee correctness we use a renderer override; alternatives are custom ops that emit SQL or an autogenerate rewriter.

If we ever want concurrent drops, options include:

  • Per-index dropConcurrently in schema.
  • A global Postgres-only config flag to drop indexes concurrently (with warnings).
  • A migration helper users can call explicitly when needed.

Partial indexes

Partial indexes are supported via postgresql_where=sa.text(...) and sqlite_where=sa.text(...) in SQLAlchemy. In ent schema, use indices: [{ ..., where: "place = 1" }] or indexWhere: "place = 1" for index: true. The clause is a raw SQL string and should reference DB column names.

Metadata

Release files for auto-schema 0.0.34

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for auto-schema 0.0.34
File Size Uploaded Provenance Actions
auto_schema-0.0.34.tar.gz 36.9 kB Without provenance Details for auto_schema-0.0.34.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for auto-schema 0.0.34
File Interpreter ABI Platform Actions
auto_schema-0.0.34-py3-none-any.whl Python 3 none any Details for auto_schema-0.0.34-py3-none-any.whl

Total release size: 72.4 kB

Release files / auto_schema-0.0.34.tar.gz

Download URL auto_schema-0.0.34.tar.gz
Size 36.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cbbf7bdfbea2e5497b0e3153ef4458b127c8dcd35a30a232e626b520335b8e87
BLAKE2b-256 checksum
How to use checksums
0ed9422744d392889f10b3e92c4e9ce1ea693b4642a14022924a9fff928763e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Release files / auto_schema-0.0.34-py3-none-any.whl

Download URL auto_schema-0.0.34-py3-none-any.whl
Size 35.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19cd284e9de313f9ad8f285b6f23d102ff4bbe0b039ca0c0e627eab897c5be3b
BLAKE2b-256 checksum
How to use checksums
184a75952971d0ee3b9ef61faae7e17a189e7ecd08114ccea5b7afcfa99bec68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Security for auto-schema 0.0.34

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.34 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page