feat: Enhance Stripe service to check for users table existence before altering
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -11,7 +11,7 @@ build/
|
|||||||
venv/
|
venv/
|
||||||
.venv/
|
.venv/
|
||||||
env/
|
env/
|
||||||
|
docs/
|
||||||
# Node
|
# Node
|
||||||
node_modules/
|
node_modules/
|
||||||
frontend/dist/
|
frontend/dist/
|
||||||
|
|||||||
@@ -48,5 +48,5 @@ EXPOSE 5000
|
|||||||
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
|
||||||
CMD curl -f http://localhost:5000/api/health || exit 1
|
CMD curl -f http://localhost:5000/api/health || exit 1
|
||||||
|
|
||||||
# Run with Gunicorn
|
# 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", "wsgi:app"]
|
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "4", "--timeout", "120", "--preload", "wsgi:app"]
|
||||||
|
|||||||
@@ -19,6 +19,13 @@ def _ensure_stripe_columns():
|
|||||||
"""Add stripe_customer_id and stripe_subscription_id columns if missing."""
|
"""Add stripe_customer_id and stripe_subscription_id columns if missing."""
|
||||||
conn = _connect()
|
conn = _connect()
|
||||||
try:
|
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()]
|
cols = [row["name"] for row in conn.execute("PRAGMA table_info(users)").fetchall()]
|
||||||
if "stripe_customer_id" not in cols:
|
if "stripe_customer_id" not in cols:
|
||||||
conn.execute("ALTER TABLE users ADD COLUMN stripe_customer_id TEXT")
|
conn.execute("ALTER TABLE users ADD COLUMN stripe_customer_id TEXT")
|
||||||
|
|||||||
Reference in New Issue
Block a user