2 ms·
> Like why is this deleted row being listed in this <select>? Did I forget to add `WHERE deleted_at IS NULL` again? This is adding more complexity but... views
by Izkata 2y ago
> Like why is this deleted row being listed in this <select>? Did I forget to add `WHERE deleted_at IS NULL` again?
This is adding more complexity but... views?
For example: rename the "foo" table to "all_foo" and "CREATE VIEW foo AS SELECT * FROM all_foo WHERE deleted_at IS NULL"
I think you could even create a trigger on the view so "DELETE FROM foo" gets replaced with an "UPDATE all_foo SET deleted_at = NOW()", but I've never tried that before.
- deleted 2y ago[deleted]
- hu3 2y agoNot bad. I forgot about the view solution. So thanks for remembering me. I haven't worked with this approach. But I might give it a try.