Files
worldwideview/scripts/safe-db-push.mjs
Antigravity AI 008e8cd01d chore(repo): hygiene improvements and onboarding fixes (Refs #86)
- chore: remove tracked .env and skills-lock.json
- chore: move military_bases.geojson to public/
- fix: correct README architecture doc hyperlink
- chore: add .nvmrc and enforce Node v20 via engines
- fix: implement safe-db-push.mjs wrapper to guard DATABASE_URL
- refactor: remove duplicate ApiKeysTab.tsx and fix imports
- docs: relax file size limit and remove TS aliases in AGENTS.md
2026-05-12 22:02:47 +12:00

15 lines
720 B
JavaScript

import { execSync } from 'child_process';
const dbUrl = process.env.DATABASE_URL || '';
const isLocal = dbUrl.includes('localhost') || dbUrl.includes('127.0.0.1') || dbUrl.includes('host.docker.internal') || dbUrl.includes('postgres:postgres@db:5432');
if (!isLocal) {
console.error("❌ ERROR: DATABASE_URL points to a remote database.");
console.error(" Running 'prisma db push --accept-data-loss' on production/staging data is forbidden.");
console.error(" If you truly need to migrate a remote db, run prisma db push manually.");
process.exit(1);
}
console.log("🔒 Local database detected. Safely running prisma db push...");
execSync('npx prisma db push --accept-data-loss', { stdio: 'inherit' });