Enable schema modification before comparison #7065

Open
opened 2026-01-22 15:44:03 +01:00 by admin · 2 comments
Owner

Originally created by @derrabus on GitHub (Nov 7, 2022).

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

In doctrine/dbal#5784, the event system of the DBAL has been deprecated. In ORM projects, the DBAL events were often used to modify the schema that the ORM generated, before it was compared to the current database. Possible use-cases are:

  • Injecting additional tables that are not managed by the ORM.
  • Adding unmapped columns to tables.
  • Replacing mapped tabled with views.
  • Adding triggers and other elements the ORM does not care about.

I think, we should create such a hook in the ORM, which would allow projects to migrate away from DBAL's event system.

Originally created by @derrabus on GitHub (Nov 7, 2022). ### Feature Request | Q | A |------------ | ------ | New Feature | yes | RFC | no | BC Break | no #### Summary In doctrine/dbal#5784, the event system of the DBAL has been deprecated. In ORM projects, the DBAL events were often used to modify the schema that the ORM generated, before it was compared to the current database. Possible use-cases are: * Injecting additional tables that are not managed by the ORM. * Adding unmapped columns to tables. * Replacing mapped tabled with views. * Adding triggers and other elements the ORM does not care about. I think, we should create such a hook in the ORM, which would allow projects to migrate away from DBAL's event system.
admin added the New Feature label 2026-01-22 15:44:03 +01:00
Author
Owner

@stof commented on GitHub (Nov 7, 2022):

The ORM already triggers \Doctrine\ORM\Tools\ToolEvents::postGenerateSchema to let event listeners modify the schema exactly at that point. And this covers at least the first 2 bullet points (I'm doing that in prod since years). For the last 2 bullet points, it depends whether such things can be achieved with the Schema API (if the Schema cannot represent them, no extension points allowing to change the Schema before comparing it will ever support them)

@stof commented on GitHub (Nov 7, 2022): The ORM already triggers `\Doctrine\ORM\Tools\ToolEvents::postGenerateSchema` to let event listeners modify the schema exactly at that point. And this covers at least the first 2 bullet points (I'm doing that in prod since years). For the last 2 bullet points, it depends whether such things can be achieved with the Schema API (if the Schema cannot represent them, no extension points allowing to change the Schema before comparing it will ever support them)
Author
Owner

@nicolas-grekas commented on GitHub (Dec 12, 2022):

This is the last issue in the v2.14 milestone, should we move it to v2.15? Or maybe just do nothing and close after @stof's comment?

@nicolas-grekas commented on GitHub (Dec 12, 2022): This is the last issue in the v2.14 milestone, should we move it to v2.15? Or maybe just do nothing and close after @stof's comment?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7065