-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Context: I believe there are valid reasons for letting multiple frontend components use the same document type. However, consider the following scenario:
- I implement a component
<Foo>and use a new document typsomething_genericwith that component. - I implement another component
<Bar>, which happens to fit the exact data model of thesomething_genericdocument type – so, I reuse that type. <Foo>and<Bar>now both save documents of typesomething_generic.
Problem: <Foo> evolves over time and now requires a completely different data model. <Bar>, however, hasn't changed and isn't expected to. So, I now need a new document type something_else and I need to migrate all <Foo>-related documents to that new type. This is problematic: How can I select and modify all something_generic documents that were created by <Foo>, without affecting those created by <Bar>
Suggested solution: Add a new component column to the document table. When saving a document of type something_generic, the <Foo> component would set component to Foo while <Bar> would set it to Bar. That way, when the above scenario occurs, we can SELECT * FROM documents WHERE type='something_generic' AND component='Foo'; and migrate all those documents to the new something_else type.
Disadvantage: We would be saving an additional field for every document that is never read under normal circumstances.
Alternative solution: Implement the component field on the document_root. With that, we would only have to persist the field once per instance of each component in the frontend.