Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RefreshDatabaseFast fails after first run #16

Open
stephenr85 opened this issue May 7, 2024 · 1 comment
Open

RefreshDatabaseFast fails after first run #16

stephenr85 opened this issue May 7, 2024 · 1 comment

Comments

@stephenr85
Copy link

In the DatabaseMigrations trait:

/**
     * Define hooks to migrate the database before and after each test.
     *
     * @return void
     */
    public function runDatabaseMigrations()
    {
        $this->beforeRefreshingDatabase();
        $this->refreshTestDatabase();
        $this->afterRefreshingDatabase();

        $this->beforeApplicationDestroyed(function () {
            $this->artisan('migrate:rollback');

            RefreshDatabaseState::$migrated = false;
        });
    }

The "migrate:rollback" call is basically reverting all of the fresh migration, so the second time the tests run, the checksum matches while the database is completely empty.

Not sure if this is due to a code update, or if there's a best practices way of avoiding this.

For now, I've overridden the runDatabaseMigrations method to remove the rollback command.

@Sairahcaz
Copy link
Member

@stephenr85 would be awesome if you could send a PR with the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants