laravel-useful-additions
laravel-useful-additions copied to clipboard
RefreshDatabaseFast fails after first run
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.
@stephenr85 would be awesome if you could send a PR with the fix!