Upgrading
Standard Upgrade
Pull the latest code and run database migrations:
cd /bayanat
sudo -u bayanat git pull
sudo -u bayanat uv sync --frozen
sudo -u bayanat uv run flask db upgrade
sudo systemctl restart bayanat bayanat-celeryflask db upgrade is idempotent. It detects what's already applied and skips it. Safe to run multiple times.
First-Time Alembic Upgrade
If upgrading from a version before Alembic was introduced, the process is the same:
sudo -u bayanat uv run flask db upgradeThe baseline migration consolidates all previous SQL migrations. It checks your database state and applies only what's missing, regardless of which version you're upgrading from.
TIP
You no longer need to manually apply SQL files from enferno/migrations/. The flask db upgrade command handles everything automatically.
Checking Status
See which migration your database is on:
uv run flask db currentCheck if your schema matches the models:
uv run flask db checkTroubleshooting
Migration fails partway through:
Alembic runs inside a transaction. If a migration fails, the entire revision is rolled back. Fix the issue and run flask db upgrade again.
Schema drift detected after upgrade:
Run flask db check. If it reports unexpected differences, this may indicate a manual schema change that wasn't captured in a migration. Contact the development team.