i have to work with an existing database (not managed with doctrine) and i want to use doctrine only for new tables in this db.
is there a way to tell doctrine to not drop the entire db on reload but only the models defined in the yaml file ?
i have to work with an existing database (not managed with doctrine) and i want to use doctrine only for new tables in this db.
is there a way to tell doctrine to not drop the entire db on reload but only the models defined in the yaml file ?
Yes, surely you can use doctrine only for some tables(not all). And it won't drop all the other tables., unless you manually run
$manager->dropDatabases();
This is how you can start using Doctine for your new tables:
Use Command Line Interface in order to automatically generate all Doctrine models(and schema) based on DB tables(you can delete unncessesary models manually).
@ gpilotino Yes, I'm having a similar problem. There seems to be NO WAY to drop and rebuild the database from within PHPUnit, (The future of Symfony testing).
Maybe it's possible in 'lime',I don't know.
So, I am having to write a reverse ->save() function that backs all the data out of the database, and then resets all the sequences so that I can do automated testing.
For those who don't want to follow in my frustration I tried both:
1) using a Task from inside of symfony:
$optionsArray=array();
$argumentsArray=array();
$optionsArray[]="--all"; $optionsArray[]="--and-load"; $optionsArray[]="--no-confirmation";
$task = new sfDoctrineBuildTask($configuration->getEventDispatcher(), new sfFormatter()); $task->run($argumentsArray, $optionsArray);
2)Executing it from outside of symfony while inside of PHP:
Doctrine_Manager::getInstance()->getCurrentConnection()->close();
exec('./symfony doctrine:build --all --and-load --no-confirmation');
The reason that I closed the connection is that Postgres, MDBOC (my db of choice) will not drop a database that has a connection. Probably is STILL some kind of problem. I tell ya, it's NEVER as easy as the simple tutorials show. And it's even WORSE with microslop products.