Spaces:
Paused
Paused
Download scripts/run_prisma_prod.py from Kraft102/widgettdc-api: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/Kraft102/widgettdc-api/resolve/main/scripts/run_prisma_prod.py
- Command line
-
hf download hf://spaces/Kraft102/widgettdc-api/scripts/run_prisma_prod.py
-
curl -L -o run_prisma_prod.py https://huggingface.co/spaces/Kraft102/widgettdc-api/resolve/main/scripts/run_prisma_prod.py
1.26 kB
| import os | |
| import subprocess | |
| import sys | |
| # Connection string for Neon DB (from previous step) | |
| DB_URL = "postgresql://neondb_owner:npg_3tJWPqo9kRsf@ep-fancy-field-aedyuut2-pooler.c-2.us-east-2.aws.neon.tech/neondb?channel_binding=require&sslmode=require" | |
| def run_migration(): | |
| print("🚀 Starting Prisma Migration to Neon DB...") | |
| # Set environment variable for this process | |
| env = os.environ.copy() | |
| env["DATABASE_URL"] = DB_URL | |
| # Command to run migration | |
| # Assuming we are in root, schema is in apps/backend/prisma/schema.prisma | |
| cmd = ["npx", "prisma", "migrate", "deploy", "--schema", "apps/backend/prisma/schema.prisma"] | |
| print(f"Running: {' '.join(cmd)}") | |
| try: | |
| result = subprocess.run( | |
| cmd, | |
| env=env, | |
| shell=True, # shell=True often needed on Windows for npx | |
| check=True, | |
| stdout=subprocess.PIPE, | |
| stderr=subprocess.PIPE, | |
| text=True | |
| ) | |
| print("✅ Migration Successful!") | |
| print(result.stdout) | |
| except subprocess.CalledProcessError as e: | |
| print("❌ Migration Failed:") | |
| print(e.stderr) | |
| print(e.stdout) | |
| sys.exit(1) | |
| if __name__ == "__main__": | |
| run_migration() | |