Describe the bug
The elastic:migrate:fresh command calls truncate() on the Laravel database query builder which closes open transactions during testing with MySQL using the RefreshDatabase trait, causing the following exception to be thrown upon tearDown():
PDOException: There is no active transaction
/Users/stevebauman/Sites/App/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:279
/Users/stevebauman/Sites/App/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:254
/Users/stevebauman/Sites/App/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:104
/Users/stevebauman/Sites/App/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:246
/Users/stevebauman/Sites/App/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:158
/Users/stevebauman/Sites/App/tests/Feature/MyTest.php:28
To Reproduce
class MyTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->artisan('elastic:migrate:fresh');
}
public function test()
{
// Create some eloquent record...
Foo::factory()->create();
}
}
Expected behavior
The migration repository should instead have all records deleted, instead of the table being truncated.
Describe the bug The
elastic:migrate:fresh
command callstruncate()
on the Laravel database query builder which closes open transactions during testing with MySQL using theRefreshDatabase
trait, causing the following exception to be thrown upontearDown()
:To Reproduce
Expected behavior The migration repository should instead have all records deleted, instead of the table being truncated.