symfony
symfony forum
Home » support » General discussion » [SOLVED]adding a table to existing project
[SOLVED]adding a table to existing project [message #21449] Mon, 12 February 2007 16:15 Go to next message
Segolas  is currently offline Segolas
Messages: 83
Registered: April 2006
Member
Hello,

I need to add a table to an existing project.

Can I simply *add* (so other tables are keeped in the file) the table specs to schema.yml ad re-run "symfony propel-build-model"?

Or do I have to *delete* previous tables from schema.yml, write the new none (so the schema contains just the new table), and re-build the model?

[Updated on: Mon, 12 February 2007 19:06]

Re: adding a table to existing project [message #21451 is a reply to message #21449 ] Mon, 12 February 2007 17:07 Go to previous messageGo to next message
pezetgee
Messages: 734
Registered: March 2006
Faithful Member
Both approaches will work.
Personally I use the first one - add new table definition.

After running propel-build-model, run propel-build-sql and symfony will create relevant "create table" sql commands for you.
Re: adding a table to existing project [message #21452 is a reply to message #21449 ] Mon, 12 February 2007 17:14 Go to previous messageGo to next message
Segolas  is currently offline Segolas
Messages: 83
Registered: April 2006
Member
thanks for interesting.

so, you build the sql, and then use the sql code for creating just the table you need to add(for example with phpmyadmin)?
Re: adding a table to existing project [message #21456 is a reply to message #21452 ] Mon, 12 February 2007 17:26 Go to previous messageGo to next message
pezetgee
Messages: 734
Registered: March 2006
Faithful Member
Yes, that's pretty much the way.

If your existing tables are empty you could run propel-build-all which will rebuild the model and insert all tables. This however will drop all the existing tables first.

Another way, good if you're adding more tables, is to backup your existing data, run propel-build-all and then restore the data.

[Updated on: Mon, 12 February 2007 17:27]

Re: adding a table to existing project [message #21462 is a reply to message #21456 ] Mon, 12 February 2007 18:24 Go to previous messageGo to next message
francois  is currently offline francois
Messages: 1627
Registered: October 2005
Faithful Member
another alternative, to rebuild the model and the whole database without losing existing data, could be the following:

// dump data to a file in the data/fixtures/ directory
$ php symfony propel-dump-data frontend my_data.yml

// rebuild the model and insert the sql to rebuild the database as well
$ php symfony propel-build-all

// populate the database with YAML files of the fixtures directory
$ php symfony propel-load-data frontend 
Re: adding a table to existing project [message #21466 is a reply to message #21449 ] Mon, 12 February 2007 19:05 Go to previous messageGo to next message
Segolas  is currently offline Segolas
Messages: 83
Registered: April 2006
Member
thanks thanks and thanks again!!
Re: adding a table to existing project [message #21467 is a reply to message #21466 ] Mon, 12 February 2007 19:11 Go to previous messageGo to next message
francois  is currently offline francois
Messages: 1627
Registered: October 2005
Faithful Member
Wait, there's more. You can do it in 2 calls instead of 3:

// dump data to a file in the data/fixtures/ directory
$ php symfony propel-dump-data frontend my_data.yml

// rebuild the model and insert the sql to rebuild the database as well and populate the database with YAML files of the fixtures directory
$ php symfony propel-build-all-load frontend


Smile
Re: adding a table to existing project [message #21508 is a reply to message #21467 ] Tue, 13 February 2007 08:59 Go to previous messageGo to next message
Skua  is currently offline Skua
Messages: 16
Registered: December 2006
Junior Member
great tip, thank you.
But when I try to run

symfony propel-dump-data frontend test_data.yml

I get the following PropelException:
"No connection params set for propel"

I have checked my database.yml and the propel.ini. All seems to be ok. I never had problems with my database settings so far.

What settings are important to run propel-dump-data ?

Martin
Re: adding a table to existing project [message #22544 is a reply to message #21508 ] Mon, 26 February 2007 23:29 Go to previous messageGo to next message
slarmore  is currently offline slarmore
Messages: 31
Registered: January 2007
Member
Same problem here.


------------------------------
Steve Larmore
slarmore aht chfund doht org
Re: adding a table to existing project [message #23263 is a reply to message #22544 ] Wed, 07 March 2007 19:17 Go to previous messageGo to next message
slarmore  is currently offline slarmore
Messages: 31
Registered: January 2007
Member
In the error:
  [PropelException]
  No sconnection params set for propel


The "propel" is the connection name. For some reason it looks for "propel" db connection instead of the "reporting" db connection. To remedy this, my databases.yml now has a propel database connection:

all:
  reporting:
    class:          sfPropelDatabase
    param:
      dsn:          pgsql://postgres@localhost/reporting
  propel:
    class:          sfPropelDatabase
    param:
      dsn:          pgsql://postgres@localhost/reporting


I'm sure I'm missing something else where I can change the database propel uses to dump data, but so far I have not found it.

Peace,
Steve


------------------------------
Steve Larmore
slarmore aht chfund doht org
Re: adding a table to existing project [message #23264 is a reply to message #23263 ] Wed, 07 March 2007 19:17 Go to previous message
slarmore  is currently offline slarmore
Messages: 31
Registered: January 2007
Member
But oddly enough, it doesn't seem to work on my production server ::sigh::

[Updated on: Wed, 07 March 2007 20:23]


------------------------------
Steve Larmore
slarmore aht chfund doht org
Previous Topic:"No connection params set for propel" exception, sfDatabaseConfigHandler and corrupt array
Next Topic:remove collection method for model class before persistence?
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software