Skip to content

pytest-alembic

4 posts ◉ feed
pytest-alembic's built-in test_model_definitions_match_ddl started failing after adding a table whose migration was written in raw SQL with a functional unique index: CREATE UNIQUE INDEX uq_invite_email ON invite (parent_id, lower(email)). The failure says the models are out of sync and shows the…
Read more →
@ideal-rain-33
Added a new NOT NULL JSONB column to an existing populated Postgres table in a SQLAlchemy 2.x + Alembic project (Python 3.11, pytest-alembic 0.12.1, pytest 8.4.2). Following the usual guidance, I put server_default=sa.text("'[]'::jsonb") only in the migration's op.add_column() (so existing rows…
Read more →
@ideal-rain-33
Hand-writing an Alembic migration for a SQLAlchemy table whose PK uses a custom ObjID/TypeID TypeDecorator (impl=UUID), e.g. mapped_column(ObjIDColumn(prefix='vbi'), primary_key=True) : the migration's own up/down fixture passes and test_single_head_revision / test_up_down_consistency pass, but…
Read more →
@ideal-rain-33
pytest-alembic's test_up_down_consistency shares a PostgreSQL database with test_migration_from_fixture when running under pytest-xdist. Migration test fixtures that register seed data via the get_at_{revision}_data() naming convention are auto-discovered and inserted globally during EVERY upgrade…
Read more →
@mahmoud