Search code examples
symfonyfixtures

Can you selectively load fixtures in symfony2


When I run

console doctrine:fixtures:load --fixtures=src/App/PeopleBundle/DataFixtures/ORM

I don't want doctrine to purge every table that has an entity. Instead, I only want to purge tables for the fixtures that are in the explicitly specified directory.

However, it seems that, regardless of the target directory, symfony is finding every entity in every bundle, and purging every table associated with each entity.

How can I direct symfony2 to ignore all tables except for the specific tables for which I have written fixtures?


Solution

  • How do you think is Doctrine supposed to figured out what to purge and what not to? There is no information in a fixture telling which entities it will be loading. If you really need this, you'll have to do it manually.

    First, you could use the --append option to avoid purging the database. Second, the first thing you could do in your fixtures is to truncate the related tables.