From a28366f0c3304988b8467864a4743d4174a50c5f Mon Sep 17 00:00:00 2001 From: ectasy663 Date: Wed, 9 Sep 2026 09:52:33 +0530 Subject: [PATCH] fix: seed FK flush order, DPS path resolution, admin_uploads Docker mount, docker-compose env additions --- backend/seed.py | 14 +++++++++++--- docker-compose.yml | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/backend/seed.py b/backend/seed.py index 708d143..f9965c3 100644 --- a/backend/seed.py +++ b/backend/seed.py @@ -72,6 +72,9 @@ def seed_local_database(): ) session.add(student_user) + # Flush users first so FK constraints for subscription/transaction are satisfied + session.flush() + # Seed Demo Student Subscription record demo_subscription = models.Subscription( id=uuid4(), @@ -98,8 +101,8 @@ def seed_local_database(): ) session.add(demo_txn) - admin_id = uuid4() - + + # admin_id is already defined above as the fixed UUID for the admin user jee_test_id = UUID("b6faa295-3bf5-4de2-a587-d72b889629c4") neet_test_id = UUID("e7c80521-825b-4c07-889a-ee646c05d762") @@ -370,7 +373,12 @@ def seed_local_database(): # --- DPS (Daily Practice Sheets) from admin_uploads JSON files --- print("Seeding DPS tests from admin_uploads...") - dps_json_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "admin_uploads") + # Resolve path: works inside Docker (/app/admin_uploads) and locally (../../admin_uploads) + _script_dir = os.path.dirname(os.path.abspath(__file__)) + _docker_path = os.path.join(_script_dir, "admin_uploads") + _local_path = os.path.join(_script_dir, "..", "admin_uploads") + dps_json_dir = _docker_path if os.path.isdir(_docker_path) else _local_path + dps_json_files = sorted(glob.glob(os.path.join(dps_json_dir, "dps_*.json"))) with Session(engine) as dps_session: diff --git a/docker-compose.yml b/docker-compose.yml index e8ac3c4..69da383 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -52,6 +52,7 @@ services: container_name: pragativeer_backend volumes: - ./backend:/app + - ./admin_uploads:/app/admin_uploads:ro ports: - "8000:8000" environment: @@ -121,6 +122,7 @@ services: - "3000:3000" environment: - NEXT_PUBLIC_API_URL=http://localhost:8000 + - NEXT_PUBLIC_PAYMENT_GATEWAY=razorpay depends_on: - backend networks: