4 ms·
oh nice. how do you recover deleted records?
by blondin 4y ago
oh nice.
how do you recover deleted records?
- ttfkam 4y agohttps://news.ycombinator.com/item?id=34207659 https://news.ycombinator.com/item?id=34207659
- ericpauley 4y agoExactly. The whole point of soft delete is data recovery, as it’s not sufficient for anything else (like auditing).
- dragonwriter 4y agoIt seems you should be able to do it fairly straightforwardly with dynamic sql with this structure, but, I don’t know why you wouldn’t just use proper history tables, rather than story only deleted records, but lumping them all into one table. I’ve never encountered a database where I needed to know about non-current records but only ever the last-before-deletion state of deleted records, whether for data recovery or any other purpose.
- ttfkam 4y agoNo dynamic SQL necessary. jsonb_populate_record(…) was made precisely for this kind of scenario. Combine with an INSERT…ON CONFLICT DO UPDATE statement and Bob's your uncle. https://www.postgresql.org/docs/current/functions-json.html https://www.postgresql.org/docs/current/functions-json.html
- nemothekid 4y ago>and without the expectation that it’ll be used to undelete data (which probably wouldn’t work for deleted_at anyway).
- deleted 4y ago[deleted]
- xupybd 4y agoI think the author is suggesting that you often can't do it with soft deletes anyway. https://brandur.org/soft-deletion#undelete https://brandur.org/soft-deletion#undelete