diff --git a/.gitignore b/.gitignore index fb03365..88e6fe5 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ build/ venv/ .venv/ env/ - +docs/ # Node node_modules/ frontend/dist/ diff --git a/backend/Dockerfile b/backend/Dockerfile index b44a8f4..db0d0cd 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -48,5 +48,5 @@ EXPOSE 5000 HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ CMD curl -f http://localhost:5000/api/health || exit 1 -# Run with Gunicorn -CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "4", "--timeout", "120", "wsgi:app"] +# Run with Gunicorn (--preload ensures DB tables are created once before forking workers) +CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "4", "--timeout", "120", "--preload", "wsgi:app"] diff --git a/backend/app/services/stripe_service.py b/backend/app/services/stripe_service.py index 1441f01..74164d9 100644 --- a/backend/app/services/stripe_service.py +++ b/backend/app/services/stripe_service.py @@ -19,6 +19,13 @@ def _ensure_stripe_columns(): """Add stripe_customer_id and stripe_subscription_id columns if missing.""" conn = _connect() try: + # Check that users table exists before altering it + table_exists = conn.execute( + "SELECT name FROM sqlite_master WHERE type='table' AND name='users'" + ).fetchone() + if table_exists is None: + return + cols = [row["name"] for row in conn.execute("PRAGMA table_info(users)").fetchall()] if "stripe_customer_id" not in cols: conn.execute("ALTER TABLE users ADD COLUMN stripe_customer_id TEXT")