headsnet / doctrine-db-copy-bundle
Copy Doctrine databases without requiring mysqldump
Installs: 2 638
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.1
- doctrine/dbal: ^3.6
- symfony/config: ^6.1
- symfony/console: ^6.1
- symfony/dependency-injection: ^6.1
- symfony/http-kernel: ^6.1
Requires (Dev)
- phpunit/phpunit: ^9.6
README
This bundle provides a Symfony command to copy an entire database schema, without any dependency on
database client binaries such as mysqldump
or mysql
.
The primary use case is for duplicating a test database for use with Paratest in CI, where access to the database binaries is not possible, for example due to them being inside a Docker container that only exposes the MySQL port 3306.
This solution is significantly faster than dumping an SQL file and then importing it.
Installation
composer require --dev headsnet/doctrine-db-copy-bundle
If you use Symfony Flex you don't need to configure anything further.
Otherwise, add the following line to your bundles.php
file:
return [ ... Headsnet\DoctrineDbCopyBundle\HeadsnetDoctrineDbCopyBundle::class => ['dev' => true, 'test' => true], ... ];
Usage
To copy test_1
to test_2
, simply run:
bin/console headsnet:copy-db <src-db> <dest-db>
To create multiple test database copies, you can use a for loop:
PARATEST_THREADS=6 for (( i = 2; i <= $PARATEST_THREADS; i++ )); do bin/console headsnet:copy-db test_1 test_$i; done
Licence
This code is released under the MIT licence. Please see the LICENSE file for more information.