Spaces:
Paused
Paused
File size: 1,260 Bytes
5a81b95 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
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()
|