Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-550

Complete/non-overridable event dispatching in DDL methods of AbstractPlatform

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Platforms
    • Security Level: All

      Description

      The default implementation provided by the AbstractPlatform class dispatches several events related to schema modifications (create table, change column and so on) and offers the ability to prevent the default behaviour by setting a flag on the dispatched event. However, it appears that some DDL operations aren't covered by this mechanism (foreign keys creation, for example, doesn't seem to be observable). Furthermore, the concrete platforms can override any of these methods, potentially leading to inconsistancies in components that expect those events to be dispatched.

      I'm working on a large modular application build on top of Symfony, in which each bundle must have its own migration classes (i.e. migrations on a per bundle basis, not at the application level), possibly with references to other parts of the schema. I used to write those classes manually using the dbal api, but this is tiedous and error-prone, and I'd like to take advantage of the mapping-based schema generation. I found that using the event system and "filtering" ddl operations to keep only the operations related to a given bundle is a clean and easy way to achieve this goal, but the issues I mentionned prevent me to complete the implementation.

      I'd be glad to hear your opinion on that topic and, providing you're interested in it, contribute in a way or another to improve the existing code.

        Activity

        Hide
        Benjamin Eberlei added a comment -

        This is not a blocker

        Show
        Benjamin Eberlei added a comment - This is not a blocker
        Hide
        Benjamin Eberlei added a comment -

        The DBAL event system is not in its best shape and definately could use some improvement. Your easiest way however would be to hook the process of generating the whole schema, and then dropping tables from those two to only contain the ones you are interested in.

        Show
        Benjamin Eberlei added a comment - The DBAL event system is not in its best shape and definately could use some improvement. Your easiest way however would be to hook the process of generating the whole schema, and then dropping tables from those two to only contain the ones you are interested in.
        Hide
        Stéphane Klein added a comment -

        That's indeed the simplest solution. Thanks a lot for your answer.

        Show
        Stéphane Klein added a comment - That's indeed the simplest solution. Thanks a lot for your answer.
        Hide
        Steve Müller added a comment -

        Benjamin Eberlei Is there anything to do here? Should the missing events be added or is that not necessary?

        Show
        Steve Müller added a comment - Benjamin Eberlei Is there anything to do here? Should the missing events be added or is that not necessary?

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Stéphane Klein
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: