Skip to content

Edit SQL models

If you modify API database tables in api/sql/models.py, use Alembic to generate and apply a migration.

  1. 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
  2. Apply the migration

    Terminal window
    alembic -c api/alembic.ini upgrade head
  3. (Optional) Revert the last migration

    Terminal window
    alembic -c api/alembic.ini downgrade -1