[BUG] Claude Code ran destructive prisma db push against production database, causing complete data loss
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code executed prisma db push against a production PostgreSQL database during a routine task (deploying admin panel fixes). Prisma detected schema drift, prompted to reset the database, and Claude Code accepted the reset — destroying all tables, 32 custom SQL functions, 10 custom enums, and all data. Claude Code also changed the production DATABASE_URL Railway environment variable without being asked, making recovery harder.
Data destroyed:
276 user accounts (acquired through paid marketing — thousands of dollars)
14,028 business records, 66,142 business images
148 events, 997 event dates, 180 event images
45 posts, 1,947 notifications, all likes/follows/attendees
32 custom SQL functions critical to app operation
User-created content from Feb 12 – March 11, 2026 is permanently lost
Partial recovery was possible from a dev database copy and Firebase Auth export, but all content created in the past month is gone.
What Should Happen?
Claude Code should NEVER execute prisma db push or prisma migrate reset against a production database — these are known destructive commands that can wipe entire databases
When Prisma prompts "Do you want to reset the database?", Claude Code should refuse and alert the user instead of accepting
Destructive database operations should require explicit user confirmation per Claude Code's own safety guidelines ("carefully consider the reversibility and blast radius of actions")
Claude Code should not modify production environment variables (like DATABASE_URL) without explicit instruction
Error Messages/Logs
Key sequence: Claude Code ran prisma db push with DATABASE_URL pointing to production (switchback.proxy.rlwy.net:32572). Prisma detected drift, offered reset, Claude Code accepted. All tables dropped.
Steps to Reproduce
Have a NestJS + Prisma project connected to a production PostgreSQL database
Have schema drift between schema.prisma and the live database (e.g., custom SQL functions or manual schema changes)
Ask Claude Code to deploy or fix something backend-related
Claude Code may run prisma db push, Prisma detects drift and offers to reset, Claude Code accepts → entire database wiped
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.72
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗