codex - 💡(How to fix) Fix Codex ran test file which removed all of the local data from database [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#18106Fetched 2026-04-17 08:32:49
View on GitHub
Comments
2
Participants
3
Timeline
9
Reactions
0
Timeline (top)
labeled ×4commented ×2unlabeled ×2closed ×1
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

0.120.0

What subscription do you have?

Chatgpt Plus

Which model were you using?

gpt-5.4 high

What platform is your computer?

Linux

What terminal emulator and version are you using (if applicable)?

No response

What issue are you seeing?

I asked Codex to improved the code quality and a bug. It automatically start writing the tests for verification and ran it.

I was working on Laravel 12 application. It used (\Illuminate\Foundation\Testing\RefreshDatabase::class) in a test file which removed all rows from every table.

This is very destructive behavior.

What steps can reproduce the bug?

Uploaded thread: 019d6829-7822-7fe3-878e-d47384f750ad

What is the expected behavior?

Codex should always ask before writing/running the tests.

Additional information

No response

extent analysis

TL;DR

Modify the test setup to avoid using RefreshDatabase trait or configure it to only reset specific tables.

Guidance

  • Review the test file using (\Illuminate\Foundation\Testing\RefreshDatabase::class) and consider alternatives that don't wipe all table data.
  • Evaluate the need for RefreshDatabase in each test and apply it selectively to minimize data loss.
  • Investigate Laravel's testing documentation for options to customize the behavior of RefreshDatabase, such as specifying which tables to reset.
  • Consider adding a prompt or confirmation step before running tests that use RefreshDatabase to prevent accidental data loss.

Example

// Instead of using RefreshDatabase globally
use Illuminate\Foundation\Testing\RefreshDatabase;

// Use it selectively within tests
public function testExample()
{
    $this->seed(); // Seed specific data for the test
    // Test logic
    $this->assertSomething();
}

Notes

The exact solution may depend on the specific requirements of the Laravel application and the tests being run. It's crucial to balance test data management with the need to prevent destructive behavior.

Recommendation

Apply workaround: Modify the test setup to avoid using RefreshDatabase trait or configure it to only reset specific tables, as this approach allows for more control over test data management without waiting for potential updates to Codex CLI.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Codex ran test file which removed all of the local data from database [2 comments, 3 participants]