Alembic Cheatsheet 07 — Multi-Database and Multi-Tenant
Cheatsheet: multidb template, schema-per-tenant env.py, parallel migrations.
Cheatsheet: multidb template, schema-per-tenant env.py, parallel migrations.
Cheatsheet: lax default, strict per model / field / call, bool-is-int gotcha, JSON vs dict input.
Cheatsheet: AsyncEngine, AsyncSession, lazy loading caveats, streaming results, run_sync escape hatch.
Alembic CI patterns: drift detection, migration round-trip tests, dry-run, deploy gates, and pre-merge checks.
When Pydantic coerces vs raises: strict mode, per-field strict, lax/strict tradeoffs at API boundaries.
Transactions and concurrency: isolation levels, savepoints, FOR UPDATE locking, optimistic locking, retry patterns, and the cross-DB differences.
Cheatsheet: structlog setup, JSON/console, contextvars, processors, trace correlation.
Cheatsheet: pytest setup, AsyncClient, real Postgres via testcontainers, factories, drift, migrations.
Cheatsheet: GitHub Actions, drift test, up-down round-trip, dry-run SQL, deploy gates.
Cheatsheet: alias variants, populate_by_name, AliasChoices for multi-alias, AliasPath for nested input.