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 know this a very old question, and it appears you are using symfony.
Try:
app/console --env=prod doctrine:schema:drop --full-database
This will drop all the tables in the DB.
For Symfony 3:
$entityManager = $container->get('doctrine.orm.entity_manager');
$entityManager->getConnection()->getConfiguration()->setSQLLogger(null);
$entityManager->getConnection()->prepare("SET FOREIGN_KEY_CHECKS = 0;")->execute();
foreach ($entityManager->getConnection()->getSchemaManager()->listTableNames() as $tableNames) {
$sql = 'DROP TABLE ' . $tableNames;
$entityManager->getConnection()->prepare($sql)->execute();
}
$entityManager->getConnection()->prepare("SET FOREIGN_KEY_CHECKS = 1;")->execute();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With