How to create and manage database migrations in the Definable backend
001_create_base_tables.py
, 002_create_models_and_agents.py
).
alembic.ini
: Contains database connection information and Alembic settingsalembic/
: Directory containing migration scripts and environment configuration:
env.py
: The Alembic environment setupscript.py.mako
: Template for generating migration filesversions/
: Directory containing migration scriptssrc/models/
directory__init__.py
filealembic/versions/
directory with a format like <revision_id>_description_of_changes.py
.
upgrade()
and downgrade()
functions.
010_create_upload_files.py
, name yours 011_your_feature_name.py
updated_at
columns as demonstrated in the example migrationsop.*
) over raw SQL when possiblealembic.ini
.__init__.py
file.alembic upgrade head
again, or specifically target the failed migrationalembic stamp <last_successful_revision>
alembic revision --autogenerate -m "description"
alembic upgrade head