dwyl/phoenix-ecto-append-only-log-example

How to deal with deletions?

开放

#7 创建于 2018年10月8日

 (8 条评论) (1 个反应) (1 位负责人)Elixir (5 个派生)auto 404
discusshelp wantedquestion

仓库指标

星标
 (82 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Although we are never deleting any records from our append only database, we still need a way to mark data as 'deleted', so it isn't shown to to users.

One solution could be to have an extra column in each table for 'deleted', and to mark that as true every time a user 'deletes' something. This would have the advantage of being easily reversible, ie. we could have a page that lists all 'deleted' items, and a button that 'undeletes' them, simply by marking 'deleted' as false.

The main issue we are facing is how to deal with deleting associations. We've come up with a way to keep associations among updated records, which should also work for deleted records (see #6). But this doesn't account for simply removing an association between two records.

The proposed solution above could work, but it might mean re-implementing a lot of what we already have. Ecto uses 'many to many' fields in schemas to automatically update composite tables. These tables currently consist of just two ids. It would probably be worth looking into how Ecto goes about updating these tables, and how easily we could instead do it ourselves.

Any suggestions or thoughts on the above two issues are welcome

贡献者指南