Database Migrations CE EE · Self-Host
Aicser uses Alembic for database schema management. CE migrations run on branch ce@head.
Apply migrations
cd server
poetry run alembic -c alembic.ini upgrade ce@head
In Docker, migrations run automatically before the server starts.
Check current revision
cd server
poetry run alembic -c alembic.ini current
Generate a new migration
After modifying a SQLAlchemy model in server/src/modules/<module>/models.py:
cd server
poetry run alembic -c alembic.ini revision --autogenerate -m "describe the change"
Review the generated file in server/alembic/versions/ before applying — autogenerate does not always detect all changes correctly. Then apply:
poetry run alembic -c alembic.ini upgrade ce@head
Migration branches
| Branch | Purpose |
|---|---|
ce@head | Community Edition schema |
heads | Applies all branches — used in EE |
Rollback
# Roll back one step
poetry run alembic -c alembic.ini downgrade -1
# Roll back to a specific revision
poetry run alembic -c alembic.ini downgrade <revision_id>