Manage database schema changes systematically with Alembic migrations
What is it
Alembic is a lightweight database migration tool that manages database schema changes over time. Think of it as “version control for your database” - it tracks changes and lets you upgrade or rollback your database structure safely.
Why we use it
The Launchpad uses Alembic because it integrates seamlessly with our SQLAlchemy models, automatically detects schema changes, and ensures all environments stay synchronized.
Where we use it
We use Alembic for all database schema changes in the project. Here’s how it works:Basic Commands:
Create Migration: ./makemigration.sh
Apply Migration: ./migrate.sh
Complete Workflow:
Modify your SQLAlchemy model (e.g., in database/event.py)
Generate migration: ./makemigration.sh → Enter migration message
Review the generated migration in alembic/versions/
Apply the migration: ./migrate.sh
For Alembic to detect your models, you must import them in alembic/env.py
# alembic/env.pyfrom launchpad.database.session import Basefrom launchpad.database.event import * # Import Event model for autogenerate# Import additional SQLAlchemy models here when you add them.