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 CONCURRENTLYis 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
DropIndexOpwithout the flag. - Alembic can render
postgresql_concurrently=True, but it does not automatically wrap it inautocommit_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
dropConcurrentlyin 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.41
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| auto_schema-0.0.41.tar.gz | 57.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| auto_schema-0.0.41-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 115.8 kB
Release files / auto_schema-0.0.41.tar.gz
| Download URL | auto_schema-0.0.41.tar.gz |
|---|---|
| Size | 57.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d10ea0cd569364c60c7e424e7dc834bb800c49b15b10aea1c2a617e3f2acd783
|
|
BLAKE2b-256 checksum How to use checksums |
b5bc1316e1e697e9030eb6cdb58b33d1c4eeab865cb25b43bde85d3e725e81a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.2
|
Release files / auto_schema-0.0.41-py3-none-any.whl
| Download URL | auto_schema-0.0.41-py3-none-any.whl |
|---|---|
| Size | 57.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91b1a4666d5f639da7892fded3217077f96ca865ba7ffc3901943f0416e3786b
|
|
BLAKE2b-256 checksum How to use checksums |
09e5a2987c8200e6679083a830be3237022ad6e5ee0ddf43fbecb5e4cc3fe12a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.2
|