I want to create a new table and then insert a specific record in a symfony 1.4 project. I can do the data insert manually, but I would like to make use of the migration infrastructure so that when different existing instances are upgraded this row will be created when the migrations are run.
Here is the sequence of migrations:
- Create a new table
email. - Insert a row into the table
email.
(Note that these are two separate consecutive migrations.)
The problem is that in this migration there is no chance to generate the base model classes, so attempting to insert the row using the normal Doctrine commands will fail.
I could use a naked SQL INSERT commands, but that seems like an admission of defeat. Is there another, more Doctrine-friendly way to do the data insert?
There is a way to do migrations. Do the following :
symfony doctrine:generate-migrations-diff– this will create the migration filesymfony doctrine:build --all-classes --and-migrateThe last line will update the Database – ie create the new table and also create the base model classes. Here are the options (related to classes on the
buildcommand)The just run the task to insert the new DB entry or use the new fixtures (using
symfony doctrine:data-load --append <filename>) file to create the entry in the DB.