Symfony teaching: build --all --and-load WITHOUT LOST RECORDINGS IN THE DATABASE

I'm new to Symfony + Doctrine, but pretty experienced in developing web applications in general (mostly using the Zend Framework). I started a new project using Symfony, and I love it.

I have a small number of fixtures in my / data / fixtures / folder that load whenever I update the circuit and do:

sf doctrine:build --all --and-load 

The problem is that adding tools is really tedious, while the interface of my application loads data pretty quickly. Thus, I load the test data into the database (using my application), but then whenever I make changes to the circuit (and run the above statement), it returns data only on what is in the devices.

In the manual, I read that the -and-append option will not overwrite data in the database. But the -all option says it resets the database.

Obviously, if I remove a column from the schema, I will lose this information, but I just want to keep my new records.

Sorry if I miss something very obvious. Thanks in advance for any help you can provide!

+4
source share
4 answers

Use symfony doctrine:build --all-classes

From the documentation ( symfony help doctrine:build ):

 You can also generate only class files by using the --all-classes shortcut option. When this option is used alone, the database will not be modified. ./symfony doctrine:build --all-classes 
+6
source

I try to ensure that my process of changing the circuit is smooth enough, and I will do it as soon as I think they are needed, and not put off. Nuking all the data that I worked with is a certain outage that will increase mental resistance and allow me to use the problematic circuit longer than I should.

So, I think that you are doing it right with the devices you have, you just need to dump more ( symfony doctrine:data-dump ) of your data entered into the user interface into the lights before rebooting. You will have to rewrite or rebuild the fixtures for some circuit changes, but this is as it is. Investing in work tools gives you the flexibility to change the circuit.

+1
source

build --all discards the database and you lose the information contained in it. --and-load loads everything you have in your fixtures back. So, as far as I know, there is not a single team to do what you need. From what I understood, the --and-load and --and-append tags are similar, as you can also re-run doctrine:data-load and not delete existing data.

So, in short, to save your data, do not run build --all , but make changes to your database through SQL, update your schema, and then just recreate the models.

0
source

You can make changes to db through the doctrine migration either independently through sql scripts (this is a safer IMO option) or manually in the database if you are developing. Usually I just rebuild the model classes to reflect new schema changes (via doctrine: build), and just do a complete removal of the db and create it periodically to make sure everything is working fine.

0
source

Source: https://habr.com/ru/post/1338701/


All Articles