Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema exclude annotation #8195

Open
ianef opened this issue Jun 25, 2020 · 9 comments
Open

Schema exclude annotation #8195

ianef opened this issue Jun 25, 2020 · 9 comments
Labels
Hacktoberfest Good issue for participating in Hacktoberfest New Feature

Comments

@ianef
Copy link
Contributor

ianef commented Jun 25, 2020

Feature Request

Q A
New Feature yes
RFC yes
BC Break no

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.

@beberlei
Copy link
Member

beberlei commented Jul 4, 2020

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.

@beberlei beberlei added Hacktoberfest Good issue for participating in Hacktoberfest New Feature labels Jul 4, 2020
@ianef
Copy link
Contributor Author

ianef commented Jul 5, 2020

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.

@beberlei
Copy link
Member

beberlei commented Jul 5, 2020

@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

@ianef
Copy link
Contributor Author

ianef commented Jul 6, 2020

@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.

@beberlei
Copy link
Member

beberlei commented Jul 6, 2020

@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).

@ianef
Copy link
Contributor Author

ianef commented Jul 7, 2020

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.

@beberlei
Copy link
Member

beberlei commented Jul 7, 2020

You might have started with master branch instead of 2.8

@ianef
Copy link
Contributor Author

ianef commented Jul 7, 2020

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.

ianef added a commit to ianef/orm that referenced this issue Jul 7, 2020
@ianef
Copy link
Contributor Author

ianef commented Jul 7, 2020

@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?

ianef added a commit to ianef/orm that referenced this issue Jul 7, 2020
@beberlei beberlei linked a pull request Jul 11, 2020 that will close this issue
simPod added a commit to simPod/orm that referenced this issue Nov 24, 2021
simPod added a commit to simPod/orm that referenced this issue Nov 24, 2021
simPod added a commit to simPod/orm that referenced this issue Nov 24, 2021
simPod added a commit to simPod/orm that referenced this issue Nov 24, 2021
simPod added a commit to simPod/orm that referenced this issue Nov 24, 2021
simPod added a commit to simPod/orm that referenced this issue Nov 24, 2021
simPod added a commit to simPod/orm that referenced this issue Nov 24, 2021
simPod added a commit to simPod/orm that referenced this issue Nov 24, 2021
simPod added a commit to simPod/orm that referenced this issue Nov 24, 2021
simPod added a commit to simPod/orm that referenced this issue Nov 26, 2021
simPod added a commit to simPod/orm that referenced this issue Nov 26, 2021
simPod added a commit to simPod/orm that referenced this issue Nov 28, 2021
beberlei pushed a commit that referenced this issue Dec 12, 2021
Co-authored-by: Simon Podlipsky <[email protected]>

Co-authored-by: Iab Foulds <[email protected]>
derrabus added a commit to derrabus/orm that referenced this issue Dec 13, 2021
* 2.11.x:
  Deprecate Setup::registerAutoloadDirectory() (doctrine#9249)
  PHPCS 3.6.2, Psalm 4.15.0 (doctrine#9247)
  Add SchemaIgnoreClasses property for doctrine#8195. (doctrine#9202)
  Remove fallbacks for old doctrine/annotations version (doctrine#9235)
  Update docs/en/reference/events.rst
  Added psalm param to abstract addFilterConstraint (doctrine#9229)
  Merge pull request doctrine#9210 from alexander-schranz/patch-2
  Fix typo assumptio--> assumption
  Update events.rst
  Completing links to `EventArgs` classes in overview table
  Using `const` for `type`
  [Documentation] Events Overview Table: Adding "Passed Argument" column
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hacktoberfest Good issue for participating in Hacktoberfest New Feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants