Created
November 21, 2023 15:48
-
-
Save Uplink03/6f52ece5c18dc12331a65c60bf95ae36 to your computer and use it in GitHub Desktop.
Refresh the damned database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// File path in Laravel project: `tests/RefreshTheDamnedDatabase.php` | |
declare(strict_types=1); | |
namespace Tests; | |
/** | |
* Quick and dirty database refresh for tests | |
* | |
* Reason: | |
* - RefreshDatabase uses transactions. That's no bueno when I'm also using transactions. | |
* - DatabaseTruncation exploded spectacularly with this beautiful error: | |
* ``` | |
* Class "Doctrine\DBAL\Driver\AbstractMySQLDriver" not found | |
* ``` | |
*/ | |
trait RefreshTheDamnedDatabase | |
{ | |
public function refreshTheDamnedDatabase(): void | |
{ | |
$this->artisan('db:wipe'); | |
$this->artisan('migrate --step --seed'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment