Ron
Ron

Reputation: 23466

How do use database fixtures for production environment

I'm wondering how to use Doctrine fixtures in a production environment. For example when I want to predefine a fixed set of permissions or a superuser etc.

The Doctrine documentation states:

Fixtures are used to load a "fake" set of data into a database that can then be used for testing or to help give you some interesting data while you're developing your application.

Therefore I don't want to use the fixtures themselfs because it would be against the concept of it.

Any ideas?

Upvotes: 3

Views: 7513

Answers (3)

Ron
Ron

Reputation: 23466

I found a great answer to this here:

Typically the recommended thing to do is to use migrations. Run the fixture code with dump-sql on, and move that into a migration that can be consistently deployed in any server.

Upvotes: 10

Wajdi Ben Abdallah
Wajdi Ben Abdallah

Reputation: 297

You need just to add this to your command line :

--env=prod

Upvotes: 2

svgrafov
svgrafov

Reputation: 2014

You can also use fixtures with --append option, that will not purge database.
Documentation.

php bin/console doctrine:fixtures:load --append --fixtures=/path/to/production/fixtures1 --fixtures=/path/to/production/fixtures2

Upvotes: 1

Related Questions