Skip to main content
AI Backend GlossaryGlossary

Alembic Migrations

Database schema version control for SQLAlchemy models.

Definition

Alembic is the official migration tool for SQLAlchemy. It tracks changes to your database schema in versioned migration files, allowing you to apply, roll back, and auto-generate schema changes from your ORM models. It's the equivalent of Django's `makemigrations` for FastAPI applications.

Why it matters for AI APIs

Without database migration management, schema changes are manual, error-prone, and hard to coordinate across environments. Alembic provides a reproducible migration history that can run in CI, on first deploy, and be rolled back safely — essential for any production application.

In FastAPI AI Kit

Alembic is fully configured with an `env.py` that loads your database URL from environment variables, an initial migration for all core models (users, API keys, jobs, embeddings), and alembic.ini ready to use. Run `alembic upgrade head` or let the startup script handle it.

Related terms