I have some problem. I work on symfony 1.4. I want to add a new column in my table and generate in php getter and setter to use it.
So In my shema.yml I add my column in my table like this:
version : {type: integer}
userName_canonical : {type: varchar(255)}
email_canonical : {type: varchar(255)}
qualifications: {type: array}
qualification_autre: {type: string}
promo: {type: boolean, default: 0}
next_request_at: {type: date, default: null}<-----
But I search everywhere and I don't know how I can modify my entity and create this column in my database. Someone know which is the command using to modify my entity in symfony 1.4 ??
Thank in advance
According to the Symfony 1.4 documentation you need to run these commands after modifying your schema file:
php symfony doctrine:build --model
php symfony doctrine:build --sql
php symfony doctrine:insert-sql
Before running these commands, please read to this documentation page under the heading 'The ORM' just to make sure those commands are what you're looking for.
Doctrine entities can then be generated via this command
php symfony doctrine:build --model
Make sure to backup any existing work before doing this however, as it may overwrite any changes to existing classes.
Before you create the new model classes (using the
doctrine:build
commands), you should create migration files.For me, the process is usually:
./symfony doctrine:generate-migrations-diff
This should create a new file in
lib/migrations/doctrine
with commands to add any new columns../symfony doctrine:build --all-classes
This will create or update the classes in
lib/{model,form,filter}/doctrine/base
to include the new columns../symfony doctrine:migrate
This actually runs the migration. Otherwise you'll get a SQL error because of the missing column. The migration clearly needs to be run on production as well; we have that as part of our deploy scripts to run every time.
If you've already built new classes, you'll need to add a few steps to the beginning of the above process:
./symfony doctrine:build --all-classes
generate-migrations-diff
step above.