Currently, the FundraisingStore is a common dependency across all bounded contexts. Updating the store means updating all bounded contexts, since composer does not allow different dependencies across sub-dependencies.
The situation is made worse by the database design in FundraisingStore, where we use the relations and the "cascade" feature to automatically create AddressChange entities when we save Donation and Membership entities. This makes the Donation and Membership domain unnecessarily depend on the AddressChange domain, which should be standalone.
To make each bounded context truly independent and maintainable on its own, I propose the following changes:
- Invert the Donation->AddressChange and Membership->AddressChange relations, by adding an `AddressChangeAssociation` table with the fields `entityType ENUM('Donation', 'Membership')` and `entityId`. Add a [[ https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/events.html#listening-and-subscribing-to-lifecycle-events | Doctrine event listener for the `postPersist` event ]] that inserts AddressChange and AddressChangeAssociation entity. Adapt the queries in the `ExportQueryBuilder` classes in the FOC.
- Move the Doctrine entities from FundraisingStore into the respective bounded contexts (Choosing a proper namespace, e.g. `DataAccess/DoctrineEntities`). Use the moved entities instead of the FundraisingStore entities.
- Remove FundraisingStore from the Fundraising Operation Center: it already imports the bounded contexts. Replace the references to FundraisingStore classes with the references to entities from the bounded contexts.
- To be discussed: How to do organize migrations? Each bounded context should have has their own migration that get picked up by FundraisingFrontend and FOC, which can have additional migrations. On the servers, we want to run all the new migrations at once, how do we chaivee that? Standalone migration configuration per-context, tied together with a script? Or a dynamic configuration, [[ https://www.doctrine-project.org/projects/doctrine-migrations/en/latest/reference/configuration.html#manually-providing-migrations | manually providing the migration classes ]]? Or something else?