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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

auto_schema-0.0.41.tar.gz (57.9 kB view details)

Uploaded Source

Built Distribution

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

auto_schema-0.0.41-py3-none-any.whl (57.9 kB view details)

Uploaded Python 3

File details

Details for the file auto_schema-0.0.41.tar.gz.

File metadata

  • Download URL: auto_schema-0.0.41.tar.gz
  • Upload date:
  • Size: 57.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.2

File hashes

Hashes for auto_schema-0.0.41.tar.gz
Algorithm Hash digest
SHA256 d10ea0cd569364c60c7e424e7dc834bb800c49b15b10aea1c2a617e3f2acd783
MD5 ace372bc2add2de1cb15878e6298fe4b
BLAKE2b-256 b5bc1316e1e697e9030eb6cdb58b33d1c4eeab865cb25b43bde85d3e725e81a0

See more details on using hashes here.

File details

Details for the file auto_schema-0.0.41-py3-none-any.whl.

File metadata

  • Download URL: auto_schema-0.0.41-py3-none-any.whl
  • Upload date:
  • Size: 57.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.2

File hashes

Hashes for auto_schema-0.0.41-py3-none-any.whl
Algorithm Hash digest
SHA256 91b1a4666d5f639da7892fded3217077f96ca865ba7ffc3901943f0416e3786b
MD5 8f261ac0969ed3401a569dee982d18f8
BLAKE2b-256 09e5a2987c8200e6679083a830be3237022ad6e5ee0ddf43fbecb5e4cc3fe12a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.41 This release

2 files

0.0.40

2 files

0.0.39

2 files

0.0.38

2 files

0.0.37

2 files

0.0.36

2 files

0.0.35

2 files

0.0.34

2 files

0.0.33

2 files

0.0.32

2 files

0.0.31

2 files

0.0.30

2 files

0.0.29

2 files

0.0.28

2 files

0.0.27

2 files

0.0.26

2 files

0.0.25

2 files

0.0.24

2 files

0.0.23

2 files

0.0.22

2 files

0.0.21

2 files

0.0.20

2 files

0.0.19

2 files

0.0.18

2 files

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

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