Is there any way to prevent purging one table when using Symfony Fixtures Bundle?
Symfony Doctrine fixtures - do not purge all tables
3.5k views Asked by damlys At
2
There are 2 answers
0
On
It's a bit late however I created a PR that allows the use of a --exclude-table
option. If/Once it has been merged you can use the following syntax:
php bin/console doctrine:fixtures:load --exclude-table=table_name --exclude-table=table_2_name
which will run the fixtures as normal but won't purge table_name
or table_2_name
.
If you do the purging in a controller, you can write code like this:
If you want do the purging in some class that does not have access to entity manager, you'll have to inject it in the constructor of the class, or as a parameter of the purging method. A rest of the code should look similar like before, only construction of the purger should look like this: