I’ve got a Doctrine Entity defined that maps to a View in my database. All works fine, the Entity relations work fine as expected.
Problem now is that when running orm:schema-manager:update on the CLI a table gets created for this entity which is something I want to prevent. There already is a view for this Entity, no need to create a table for it.
Can I annotate the Entity so that a table won’t be created while still keeping access to all Entity related functionality (associations, …)?
Eventually it was fairly simple, I just had to subclass the
\Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommandinto my own CLI Command. In that subclass filter the$metadatasarray that’s being passed toexecuteSchemaCommand()and then pass it on to the parent function.Just attach this new subclassed command to the ConsoleApplication you are using in your doctrine cli script and done!
Below is the extended command, in production you’ll probably want to fetch the
$ignoredEntitiesproperty from you config or something, this should put you on the way.PS: credits go to Marco Pivetta for putting me on the right track. https://groups.google.com/forum/?fromgroups=#!topic/doctrine-user/rwWXZ7faPsA