Hello!

I have a question: How to organize the process of rolling the combat database when a project is deployed?

Behind the brackets leave the update code, dependencies, and so on.

And the details are:

Symfony 2.8.6 + MigrationsBundle + DataFixturesBundle + Mysql 

The schemas of the base are in the migrations, the basic data of the base for the project are loaded in fixtures. There is also a production base with goods, orders, etc.

I deploy the database to the test state in the following way:

 php app/console doctrine:migrations:migrate php app/console doctrine:fixtures:load 

After that, I need to roll up current data from the production base to this database, and this is where the plug-in occurred. Just make a dump and roll it will not work due to the fact that the production database already has the original records that are created by fixtures, and when importing errors like duplicated will take off.

Please share your experience on how to solve such problems, or throw me some useful link.

    1 answer 1

    Fixtures are not needed in production. Fixtures can be needed to deploy devs or a test environment, but they have nothing to do with production.

    Migrations too - their zero point of reference should coincide with the current production data structure. Those. The first migration does not create a base; it makes the first change that is needed in an already live database.

    Sometimes we did the first migration, which creates the original structure. But then you must first make a record in manual production that this migration has already been done there.

    Therefore, for each deployment, you only need php app/console doctrine:migrations:migrate

    • By fixtures clear. - Victor
    • one
      Since the project was written from scratch, there is no source database. And all the development went through migration. That is, I get the actual database scheme just by doing the migration. It turns out the initial data, such as settings, I need to add in the migrations, and on the prod just roll up the migration, after making a dump (reinsurance). - Victor
    • one
      Yes, that's it. Some null data, like currencies, cities, countries, etc., are added to migration too. - Dmitry Malyshenko
    • @Victor fixtures are designed to fill the database with toast data, which would then test the application based on this data. You do not need to flood them for battle - ghost404