Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions backend/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,14 @@ def create_app(env=None):

# ── Development safety: ensure base tables exist ───────────────────────
# If a local DB is created in a partially migrated state, endpoints like
# login will crash with "no such table". For development only, auto-create
# tables when the critical `users` table is missing.
if env in ("development", "testing"):
with app.app_context():
from . import models # noqa: F401

try:
db.create_all()
except Exception as e:
app.logger.error(f"Auto-migration failed: {str(e)}")
# login will crash with "no such table". Auto-create missing tables.
with app.app_context():
from . import models # noqa: F401

try:
db.create_all()
except Exception as e:
app.logger.error(f"Auto-migration failed: {str(e)}")

# ── Blueprints ────────────────────────────────────────────────────────────
from .routes.auth import auth_bp
Expand Down
7 changes: 6 additions & 1 deletion backend/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ class ProductionConfig(Config):
"""Production Configuration."""

DEBUG = False
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL") or "sqlite:///production.db"

db_url = os.environ.get("DATABASE_URL")
if db_url and db_url.startswith("postgres://"):
db_url = db_url.replace("postgres://", "postgresql://", 1)

SQLALCHEMY_DATABASE_URI = db_url or "sqlite:///production.db"


config = {
Expand Down
1 change: 1 addition & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ urllib3==2.6.3
Werkzeug==3.1.5
wsproto==1.3.2
yarg==0.1.10
psycopg2-binary==2.9.9
Loading