-
Notifications
You must be signed in to change notification settings - Fork 21
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
Cascading delete (remove related entities / references when deleting an entity) #220
Comments
I am not really in to the EntityMapperService, but we should definetly not have "dead" relations. The sougesstion sounds good and not to complicated |
This is somewhat related to the overall topic of how we manage related entities in the database (#108). But relational-pouch doesn't seem to offer this at the moment either pouchdb-community/relational-pouch#82 |
If we implement a cascading delete of related records, we should consider restricting the rights to delete to admins only. Anyway, deletion is usually something users wouldn't want, as they loose all the context. Archiving entities (i.e. flagging them to be hidden) would often be a better option, I guess. |
Use case scenarios & requirement specifications:When deleting a ("primary") entity P there may be the following related scenarios: P has a property that references another entity
P is referenced by another ("secondary") entity S1 (exclusively, i.e. that secondary entity does not reference any further entities)
P is referenced by another entity S2, where P is the only reference in that property but S2 has another property that also references some other entity
P is referenced by another entity S3 which also references other primary entities in the same property
Configurable role/importance of an entity reference property?Should we make entity reference properties in the schema configurable to flag their importance? e.g.
example schema: ChildSchoolRelation: childId = primary & schoolId = primary Manual review of referenced secondary entities?Use case: A note is referencing multiple children. The text contains sensitive personal information about each of the children. The user now deletes one of the referenced Child entities. This is a case of S3 and we very likely should not delete that note (the other referenced children are still in the database). Is it feasible to show the user certain related entities to decide case by case to update or delete them? Possible approaches:
in case of anonymization: (how) could the user flag a note as "text is clear of personal data about P" without removing the link completely (e.g. to keep the record of someone having participated in an event)? also see scenarios for anonymization: #1674 (comment) |
Good collection of the possible cases. I agree with the 3 roles even though I expect it to be very difficult to build a good review workflow that brings the user through all data. |
when implementing this, revisit the current (incomplete) logic of |
closes #220 --------- This functionality has been developed for the project “codo”. codo is developed under the projects “Landungsbrücken – Patenschaften in Hamburg stärken” and “openTransfer Patenschaften”. It is funded through the program “Menschen stärken Menschen” by the German Federal Ministry of Family Affairs, Senior Citizens, Women and Youth. More information at https://github.com/codo-mentoring “Landungsbrücken – Patenschaften in Hamburg stärken” is a project of BürgerStiftung Hamburg in cooperation with the Mentor.Ring Hamburg. With a mix of networking opportunities, capacity building and financial support the project strengthens Hamburg’s scene of mentoring projects since its founding in 2016. The “Stiftung Bürgermut” foundation since 2007 supports the digital and real exchange of experiences and connections of active citizens. Within the federal program “Menschen stärken Menschen” the foundation as part of its program “openTransfer Patenschaften” offers support services for connecting, spreading and upskilling mentoring organisations across Germany. Diese Funktion wurde entwickelt für das Projekt codo. codo wird entwickelt im Rahmen der Projekte Landungsbrücken – Patenschaften in Hamburg stärken und openTransfer Patenschaften. Er ist gefördert durch das Bundesprogramm Menschen stärken Menschen des Bundesministeriums für Familie, Senioren, Frauen und Jugend. Mehr Informationen unter https://github.com/codo-mentoring “Landungsbrücken – Patenschaften in Hamburg stärken” ist ein Projekt der BürgerStiftung Hamburg in Kooperation mit dem Mentor.Ring Hamburg. Mit einer Mischung aus Vernetzungsangeboten, Qualifizierungsmaßnahmen und finanzieller Förderung stärkt das Projekt die Hamburger Szene der Patenschaftsprojekte seit der Gründung im Jahr 2016. Die Stiftung Bürgermut fördert seit 2007 den digitalen und realen Erfahrungsaustausch und die Vernetzung von engagierten Bürger:innen. Innerhalb des Bundesprogramms „Menschen stärken Menschen” bietet die Stiftung im Rahmen ihres Programms openTransfer Patenschaften Unterstützungsleistungen zur Vernetzung, Verbreitung und Qualifizierung von Patenschafts- und Mentoringorganisationen bundesweit. Co-authored-by: codo-mentoring <117934638+codo-mentoring@users.noreply.github.com> Co-authored-by: Simon <simon@aam-digital.com>
🎉 This issue has been resolved in version 3.26.0-master.21 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
🎉 This issue has been resolved in version 3.26.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Issue Summary
When deleting an entity that is referenced in other entities (e.g. its id is stored in Note entities, etc.), we are currently neither deleting these related records nor removing the reference. This leads to dead references and subsequently to errors (see #874). We therefore need to implement a more sophisticated delete functionality.
Requirements:
Possible approaches:
original comment
As discussed in #218, currently we do not look at foreign key relationships when deleting entities at all. When someone deletes e.g. a child, the notes relating to that child keep the reference to a (now deleted) Entity causing some errors. Aside from the error-handling, we should also focus on this root-issue.
I can imagine that a feasible workaround would be to extend
entity.ts
to have some (abstract) lifecycle-methodonBeforeDelete(em: EntityMapperService)
, where each Entity-Subclass (like Child) can define steps to remove foreign references through the EntityMapperService passed as an argument.This should work relatively independent of the Database layer just within our Entity system. It should be especially easy for Entities like ChildSchoolRelation that should be deleted with the Child.
What are your thoughts on this?
The text was updated successfully, but these errors were encountered: