0
votes

Scenario

We want to autofill a table with new static content with doctrine, ideally with something like a fixture class or similar.

We follow the simple development life-cycle with development to staging to production. And we are using Doctrine v2.6 with Symfony v3.4. Every release step is executed by an Jenkins job.

For development and staging we use the very useful and simple doctrine-fixtures-bundle to auto-fill our database with test-datasets. The database-schema is auto-generated by doctrine:schema:update on basis of our entities.

I've tried to use the fixtures also for production but even with doctrine:fixtures:load --fixtures=src/MyBundle/DataFixture/ORM/MyFixture.php it is purging the whole database. Then I read something about the --append command to prevent doctrine from purging the database. But then it will append the datasets in every release process (?). Nevertheless, it also feels like a very bad practice.

What I'm wondering

Is it possible to truncate the table, load table records with static data loaded from a class that can be executed via a command line? Or is there a completely different (and clean) way for such a case? Is the doctrine:migration bundle the real way to go?

Thanks for your help!

1
why are you not writing migrations? They exist for the purpose of updating production environments on deployment.rkeet

1 Answers

0
votes

You should create a Command for populate tables.

https://symfony.com/doc/current/console.html