Edit SQL models
If you modify API database tables in api/sql/models.py, use Alembic to generate and apply a migration.
-
Generate a migration
Terminal window alembic -c api/alembic.ini revision --autogenerate -m "message"Feed change needs migrate data, edit the revision file.
Directoryapi/
Directoryalembic/
- alembic.ini Alembic configuration file
- env.py
- script.py.mako
Directoryversions/ Generated migrations files
- …
-
Apply the migration
Terminal window alembic -c api/alembic.ini upgrade head -
(Optional) Revert the last migration
Terminal window alembic -c api/alembic.ini downgrade -1