fix: seed FK flush order, DPS path resolution, admin_uploads Docker mount, docker-compose env additions

This commit is contained in:
2026-09-09 09:52:33 +05:30
parent 4364fdf9ec
commit a28366f0c3
2 changed files with 13 additions and 3 deletions

View File

@@ -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: