feat: Enhance Stripe service to check for users table existence before altering

This commit is contained in:
Your Name
2026-03-19 01:46:13 +02:00
parent 140aaf7904
commit 759bcd2437
3 changed files with 10 additions and 3 deletions

2
.gitignore vendored
View File

@@ -11,7 +11,7 @@ build/
venv/
.venv/
env/
docs/
# Node
node_modules/
frontend/dist/

View File

@@ -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"]

View File

@@ -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")