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
- 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
- Apply migrations:
./migrate.sh
- Check current version:
alembic current
- View history:
alembic history
- Rollback:
alembic downgrade -1