Alembic Textbook Ch. 5 — Online Schema Changes (Zero-Downtime Patterns)
Zero-downtime migrations: expand-contract, batched backfills, CONCURRENTLY, NOT VALID FK, and pg_repack.
Zero-downtime migrations: expand-contract, batched backfills, CONCURRENTLY, NOT VALID FK, and pg_repack.
Composing models: nesting, generics with TypeVars, discriminated unions, recursive models.
Postgres locking patterns: SELECT FOR UPDATE, NOWAIT, SKIP LOCKED, advisory locks, application locks, deadlock retry.
Selecting rows in SQLAlchemy 2.0: select(), where, joins, group_by, aggregates, subqueries, CTEs, scalars vs rows.
Dependency injection in FastAPI: Depends, scopes, sub-deps, class-based deps, lifecycle (startup/shutdown), and the patterns from production.
Multi-DB migrations via Alembic: -t multidb template, schema-per-tenant strategies, parallelism.
Custom types via Annotated, RootModel for primitive-typed root, TypeAdapter for arbitrary types, dataclass integration.
LISTEN/NOTIFY patterns: real-time event delivery, queue wake-up, payload limits, and combining with the outbox pattern.
Relationship() in depth: configuration, loading strategies, N+1 prevention, association tables, polymorphic patterns.
Auth and authz in FastAPI: passwords, JWT, OAuth2 / OIDC, sessions, passkeys, RBAC, scopes, and security best practices.