BackAnt includes Alembic (Documentation Index
Fetch the complete documentation index at: https://docs.backant.io/llms.txt
Use this file to discover all available pages before exploring further.
alembic~=1.12.0) in requirements.txt for database migrations.
How tables are created
In development, BackAnt takes a code-first approach:Base.metadata.create_all(engine) in init_db() creates any tables that don’t yet exist on every startup.
This means for new routes, you don’t need a migration — just run docker-compose up --build and the table is created automatically.
When you need Alembic
Alembic is needed when you make changes to existing tables — adding columns, renaming columns, changing types, adding indexes.create_all() does not modify tables that already exist.
Setting up Alembic
Initialize Alembic from the project root:alembic.ini to set your database URL:
alembic/env.py to point at BackAnt’s Base:
Base.metadata is referenced:
Generating a migration
After changing a model (e.g. adding aphone column to Users), generate a migration:
upgrade() / downgrade() script in alembic/versions/.
Applying migrations
Rolling back
CLEAR_DB in development
For rapid iteration during development,CLEAR_DB=True in your .env drops all tables and recreates them from scratch on every restart. This is faster than running Alembic but destroys all data:
Migration checklist
- Modify the SQLAlchemy model in
api/models/ - Run
alembic revision --autogenerate -m "description" - Review the generated migration in
alembic/versions/ - Run
alembic upgrade head - Rebuild your Docker image for deployment