You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Agent executed destructive database command (alembic downgrade base) without user confirmation — data loss #26913
Bug Report: Destructive database operation without user confirmation
What happened
During a coding session implementing a feature (adding 3 branding columns to a PostgreSQL database), the Claude Code agent (Opus 4.6) executed a destructive database command without asking for user confirmation:
cd /path/to/backend && .venv/bin/python -m alembic downgrade base && .venv/bin/python -m alembic upgrade head
This command dropped all 21 tables in the database and recreated them empty, destroying all user data.
Context
The agent had already successfully added the new columns using safe ALTER TABLE ADD COLUMN statements — the schema was already correct
The migration file (day0.py) had been updated for future clean installs
There was zero need to run alembic downgrade base — it was executed as a "verification step" without considering it would wipe all data
This happened twice in the same day to the same user
What should have happened
The agent's own system instructions explicitly state:
"Carefully consider the reversibility and blast radius of actions... for actions that are hard to reverse, affect shared systems beyond your local environment, or could otherwise be risky or destructive, check with the user before proceeding."
"When you encounter an obstacle, do not use destructive actions as a shortcut"
The agent should have:
Recognized that alembic downgrade base drops all tables (irreversible, destructive)
Asked the user for confirmation before executing
Or simply skipped the step since the ALTER TABLE commands had already succeeded
Impact
All user-generated data was permanently lost: ideas, LinkedIn posts, prospects, engagement actions, experiences, API keys, audit logs, persona configuration, workspace customization
Estimated loss: ~€1,000 in accumulated work and data
Only seed data (pillars, platforms, book chapters, templates) could be restored from code
Environment
Claude Code CLI with Opus 4.6 model
macOS Darwin 25.3.0
PostgreSQL database via Alembic migrations
FastAPI + SQLAlchemy 2.0 async backend
Suggestion
Consider adding alembic downgrade (and similar migration rollback commands like prisma migrate reset, django migrate zero, etc.) to the list of commands that always require explicit user confirmation, similar to how git push --force, rm -rf, and git reset --hard are treated.
Database migration commands that drop tables should never be executed automatically without user consent.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.
Activity
github-actions commentedon Feb 19, 2026
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
ThatDragonOverThere commentedon Feb 25, 2026
Adding to the Evidence Chain
Same pattern as #23913 (2,229 files), #27063 (60+ tables), and #27507 (backtest data deleted, no prompt). Permission system has multiple documented failure modes: explicit denial ignored (#27002), multi-line commands bypass allow rules (#15742), compaction loses safety instructions (#9796). Cross-linking for engineering visibility.
github-actions commentedon Mar 26, 2026
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
github-actions commentedon Apr 3, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.