Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

symfony doctrine:build --all --and-load WITHOUT LOSING RECORDS IN DATABASE

I am new to Symfony+Doctrine, but fairly experienced with web application development in general (mostly using Zend Framework). I have started a new project using Symfony, and I'm loving it.

I've got a handful of fixtures in my /data/fixtures/ folder which get loaded whenever I update the schema and do a:

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

The problem is, adding fixtures is really tedious, whereas my app interface is pretty quick to load data with. So, I load testing data into the database (using my app), but then whenever I make a change to the schema (and run the above statement), it reverts the data to just what's in the fixtures.

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

Obviously if I delete a column from the schema then I would lose that information, but I just want to preserve my new records.

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

like image 620
captainclam Avatar asked Feb 25 '23 04:02

captainclam


1 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
like image 186
Andrew Burns Avatar answered Apr 28 '23 08:04

Andrew Burns