Skip to content

Commit

Permalink
[bug] sqlite does not support --if-exists (fixes zenstruck#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Oct 8, 2020
1 parent 1138cf0 commit 4419a41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: true
matrix:
php: [7.2, 7.3, 7.4]
stability: [prefer-lowest, prefer-stable]
Expand Down
13 changes: 8 additions & 5 deletions src/Test/DatabaseResetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ public static function resetDatabase(KernelInterface $kernel): void
$registry = $kernel->getContainer()->get('doctrine');

foreach (self::connectionsToReset($registry) as $connection) {
self::runCommand($application, 'doctrine:database:drop', [
'--connection' => $connection,
'--if-exists' => true,
'--force' => true,
]);
$dropParams = ['--connection' => $connection, '--force' => true];

if ('sqlite' !== $registry->getConnection($connection)->getDatabasePlatform()->getName()) {
// sqlite does not support "--if-exists" (ref: https://github.com/doctrine/dbal/pull/2402)
$dropParams['--if-exists'] = true;
}

self::runCommand($application, 'doctrine:database:drop', $dropParams);

self::runCommand($application, 'doctrine:database:create', [
'--connection' => $connection,
Expand Down

0 comments on commit 4419a41

Please sign in to comment.