The view point i can add in solving the problem above is that The key insight from this case is that Flask-Alembic migration errors often mask the real problem: code that accesses the database during module import, before the database is properly initialized. This works locally because tables exist, but fails on fresh deployments.