How to make a change on the database?

Discussion relating to version 1.2.x stable

How to make a change on the database?

Postby xare » Tue Jun 29, 2010 3:57 pm

Hi have just taken over a project another programmer started which is online. This project runs on symfony 1.2.11

In order to develop it further I need to perform changes on the Database tables by adding columns and make new tables.

I have understood by reading the jobeet tutorial what is the process of creating a database and adding data to it using symfony.

This process consists basically of six steps:
1. Write down the structure on config/schema.yml
2. Generate the sql statements
php symfony propel:Build --sql
3. Create the tables into the DB
php symfony propel:insert-sql
4. Generate the model
php symfony propel:build --model
or better
php symfony propel:build -all
5. Create data files at /data/fixtures.
6. Run
php symfony propel:data load

This process is very good to start a project but what is much more scary is to perform a change on the data base, build or update the models and be able to retrieve data after that model has been created.

The database has grown so much that even if we make backups we pretend to make such changes and make sure everything goes all right avoiding as much as we can to delete the data or regenerate it.

I want to ask if this process would be the correct one.
1. Go to the database and add a column on the desired table
2. Run php symfony propel:build --model and php symfony propel:build --forms in order to update the model and form files related to the table where the change has been performed

I do not want to run any order that would change or alter the data that is already inside the database.

Is my strategy appropriate? Am I missing something?

Thanks so much for your help in advance.

xare
xare
Junior Member
 
Posts: 14
Joined: Tue Jun 08, 2010 2:50 pm

Re: How to make a change on the database?

Postby DBA_Alex » Tue Jun 29, 2010 6:03 pm

That's the way to do it. Just make sure you also update your schema file before you build your model, forms, and filters.

Building the classes does not modify the database in any way - just updates your project to handle the new database setup. Make sure that you modify the database as well - otherwise problems may occur.

Good luck :)~ :-)~ :smile:
Currently Using
---------------------------
Symfony 1.4/Doctrine 1.2
MySQL 5.1
DBA_Alex
Faithful Member
 
Posts: 276
Joined: Mon Jul 28, 2008 4:59 pm
Location: North Carolina, USA

Re: How to make a change on the database?

Postby xare » Wed Jun 30, 2010 8:49 am

I have a question.

Is there a way to create schema.yml from the database structure?

I have a huge DB with nearly 60 tables and the schema.yml is not updated so I have to either write it down from 0 or there is a way to create it from the database structure?

Thanks
xare
Junior Member
 
Posts: 14
Joined: Tue Jun 08, 2010 2:50 pm

Re: How to make a change on the database?

Postby xare » Wed Jun 30, 2010 9:11 am

OK I have found the solution

by running php symfony propel:build-schema I got my schema.yml updated.

Now another one, the php symfony propel:build --model on the 1st run it creates the base model files and also the empty ones for customisations. I imagine that now it will not replace them.
xare
Junior Member
 
Posts: 14
Joined: Tue Jun 08, 2010 2:50 pm


Return to symfony 1.2

Who is online

Users browsing this forum: No registered users and 0 guests