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 ?
I know this a very old question, and it appears you are using symfony.
Try:
This will drop all the tables in the DB.
You can find a task I use to truncate all tables from a db at this gist: https://gist.github.com/1154458
The core code is:
Old question, but adding for a future soul.
Based on Meezaan-ud-Din's answer quickly found it for Zend Framework 3 + Doctrine 2
Do NOT use in production
orm:schema-tool:drop
to "drop" database--full-database
to wipe out everything in database which is managed by Doctrine!--force
(or-f
)--dump-sql
to show the SQL being executed. May be combined with the-f
flag.Complete code for execution found in class:
\Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand
For Symfony 3:
I this Symfony command to drop all tables:
I added flag --force after get a caution message.
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
This is how you can start using Doctine for your new tables:
Setup DB Connection
Setup Doctrine's files/directory structure
Use Command Line Interface in order to automatically generate all Doctrine models(and schema) based on DB tables(you can delete unncessesary models manually).