M
M
misha912012-06-18 17:14:25
symfony
misha91, 2012-06-18 17:14:25

How to extend DB (add fields to tables) in symfony 1.4?

Need to add fields to some tables. As I understand it, you need to edit the yml file schema. It is necessary that symfony picks up, adds fields to tables in the database and methods to already created classes. How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nutz, 2012-06-18
@nutz

The easiest way here is to use migrations (although at first it seemed cumbersome to me, but in the end it is very convenient).
made changes to schema.yml
./symfony doctrine:generate-migrations-diff - created scripts for changing tables (specifically here - scripts are built based on the difference between existing models and the base)
./symfony doctrine:migrate - applied changes in the database
./ symfony doctrine:build-model - generated a model according to schema.yml

K
Konstantin, 2012-06-18
@Norraxx

If you already have a database ready, then edit the fields in schema.yml, then generate models, forms and filters (php symfony propel:build-model, -form, -filter). Write ALTER TABLE and edit the database manually, because (at least Propel) overwrites the database, removing all tables!!! Read carefully what Symfony asks you. To help you data/sql/lib.model.data.sql, approximately in such a file there should be the structure of the entire database (it is easier to write alter tables this way).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question