Open ianef opened 4 years ago
It would be better if we have a list of classes in Doctrine\ORM\Configuration
that is checked in SchemaTool::processingNotRequired
instead, because all metadata increases size of the cache.
Instead of a class list, maybe even better to have a callable like setSchemaAssetsFilter
that gets passed the ClassMetadata
to determine if filtered or not.
I guess a list of classes would do, callbacks for something like this seem like an archaic method of processing this. With regard to cache size, the number of entities that are likely to implement my suggested annotation in a project would be very minimal.
I honestly don't care how it is done, I would prefer it to be via configuration rather than a callback though. I would just like to be able to use migrations.
@ianef alright, from my POV if you build it with a map of entities to skip, I am going to merge it for 2.8
@beberlei Can you point me at a Symfony dev repo that I can easily pull my fork of doctrine/orm 2.8 into, trying to shoehorn it into a standard framework builds seems a tad tricky, the pinch point seems to be the doctrine/doctrine-bundle which is restricting packages and preventing doctrine/persistence 2.0.
@ianef you should implement it with a clean checkout of doctrine/orm and by adding a test to the SchemaToolTest
class, Symfony application setup is not necessary here. Let me know if you need help setting up the test or running it (execute php vendor/bin/phpunit
).
I've created PR #8202 for this, hope it looks OK to you.
Hmmm, not sure where all those other commits came from, there were 2 of mine! I guess somethings gone wrong here.
You might have started with master branch instead of 2.8
Well I thought I checked out 2.8.x but it says 3.0.x in composer.json, deep joy! I’ll delete the PR and do it again, it’s not a big change.
@beberlei PR #8203 has now checked OK and is waiting for review. As I made my initial changes on master do you want me to do a PR for that too?
Feature Request
When using migrations or schema operations, there are facilities to ignore tables via schema_filter setting, see Ignoring Custom Tables.
However there are many circumstances where entities should not be included for consideration in the schema. For example entities based on views, multiple entities for the same table or view for different sections of a project or serialisation requirements. Relying on excluding items just by the table name does not work for a lot of real world situations.
Currently there is no way to prevent a normal entity from being excluded in the schema list, this can cause schema failures and the inability to use the migration or schema tools in Doctrine.
I would like to propose adding a @SchemaExclude annotation which could be tested for in the SchemaTool::procesingNotRequired method and prevent the entity table from being added to the schema table list.
Many thanks. Ian.