anthropics / anthropics/claude-code

Ran a destructive tinker/migrate:fresh command against the live app DB instead of an isolated test DB

Đang mở
#90,808 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
area:bash area:permissions data-loss duplicate platform:windows
Ngôn ngữ chính
Python
Star
145k
Fork
23.1k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

While debugging inside a Laravel project, Claude Code (main agent loop, not a subagent) ran `php artisan tinker` scripts to inspect and fix data live, and at one point ran `migrate:fresh` inside one of those scripts to get a "clean slate" for reproducing a bug. It treated this as safe/isolated debugging.

It was not isolated. The project's `phpunit.xml` correctly points `php artisan test` at an in-memory SQLite DB, but there is no `.env.testing` file, so `tinker` and `migrate --env=testing` both silently fall back to the real `.env` and hit the actual live database. `migrate:fresh` drops every table. This wiped real user data (accounts, shift records, personnel records, leave applications, protocols, etc.) down to almost nothing. It was only partially recoverable from a stale backup, permanently losing roughly 1.5 days of real work.

This is the second time this specific failure mode has happened in this project. There was no explicit confirmation step before the destructive command ran -- the model reasoned it was acting on a disposable/isolated database and proceeded without pausing to check.

Suggested improvements:
- Before running `migrate:fresh`, `migrate:rollback`, `db:wipe`, or a `tinker` script containing writes/deletes, more strongly weigh whether the target could be a live database, especially when no `.env.testing` is present to prove isolation.
- Treat `tinker` as no less dangerous than raw SQL by default, not as a "safe debugging" tool.

Environment: Windows 11, Laravel + SQLite, Claude Code CLI (main session, Sonnet 5).

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Start by tracing the Claude Code main agent loop that executes shell commands, using the reported `php artisan tinker` and destructive migration commands as the reproduction path. Review how the absence of `.env.testing` and the project’s `phpunit.xml` affect isolation. Done means risky database operations and write-capable tinker scripts identify possible live targets and require explicit confirmation before execution.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
laravel, php, sqlite
Lĩnh vực
cli, databases, security
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.