Description
Currently, deleted topics are permanently deleted, including all versions and associations. Instead, consider moving them to a hidden area so they can be recovered later.
Considerations
Key Conflicts
This would require renaming deleted topics to avoid key conflicts, and storing attributes necessary for resurrecting the topics (e.g., OriginalKey
, OriginalParentID
).
Storage
These could be stored in e.g., Root:Deleted
. But then they will be fully loaded and cached by ITopicRepository.Load()
. An alternative would be to store them in a Deleted
root topic. This way, a list of deleted topic could be retrieved using e.g., ITopicRepository.GetDeletedTopics()
, which only lists the e.g., unique key of each top-level deleted topic. This avoids issues such as special handling for Move()
, Save()
, and Rollback()
in the OnTopic Editor. In this model, a RestoreTopic
stored procedure would be similar to LoadTopic
, but would additionally return incoming associations.
Associations
Associations with the deleted topic graph pose a problem. The best option is to delete the associations via versioning, so we still have a historical record of them. This would require, at minimum, a RestoreTopic
stored procedure which deletes the last association to and from each restored topic—which will be its deletion. It will then need to return these associations so that they can be restored in memory.
Note: This record needs to be deleted so it’s not treated as a version moving forward.
Recursive Delete
Descendants should be kept as part of the deleted topic, as this
- allows the entire tree to be restored, and
- it isn’t possible to restore topics if their parent is missing.
API
If it weren’t for associations, this could all be handled superficially via the OnTopic Editor. Given the associations issues, though, this will likely require e.g.,
ITopicRepository.Restore(uniqueKey)
[dbo].[RestoreTopic]
It could also include an API for permanent deletion of (individual?) topics, but my inclination is to handle that manually, similar to version compression, at least for the initial version.