Skip to content

[BUG] Wipe out a database with improper Laravel command #37439

@dgillier

Description

@dgillier

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Description:

Claude Code ran a laravel command: php artisan migrate:fresh --env=testing to fix a test database schema issue. The project had no .env.testing file. Laravel's --env=testing flag
fell back to .env, which pointed to the main production-equivalent local database (xxx). All data was permanently destroyed.

What happened step by step:

  1. Tests were failing due to a missing column default in the test database (xxx_testing)
  2. Claude Code ran ./vendor/bin/sail artisan migrate:fresh --env=testing intending to rebuild the test database
  3. No .env.testing file existed — Laravel silently fell back to .env
  4. .env pointed to xxx (the main local database)
  5. migrate:fresh dropped all tables and all data in xxx — users, events, everything — with no warning and no confirmation prompt

Expected behaviour:

Before executing any destructive database command (migrate:fresh, migrate:reset, db:wipe), Claude Code should:

  • Verify which database will actually be targeted
  • Detect when --env=X has no corresponding .env.X file and warn that it will fall back to the default
  • Require explicit user confirmation before proceeding with any irreversible, destructive operation

Actual behaviour:

The command was executed immediately with no verification, no warning about the missing .env.testing file, and no confirmation prompt. All local data was
permanently lost.

Why this matters:

migrate:fresh is irreversible. There is no undo. The risk of targeting the wrong database is high and well-known in Laravel projects. This class of command
should never be run without first explicitly confirming the target database with the user, regardless of how confident the agent is about the intent.

What Should Happen?

This should have not happens, database fully deleted by claude action…

Error Messages/Logs

Steps to Reproduce

don't know

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.81

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions