[Answered ]-Soft Delete. Move records or create "deleted" column

1πŸ‘

I agree with @web-engineer, adding a nullable column with the datetime of when the row has been soft-deleted is the best. I used this ressource to do this.

And to answer the second part of your question, yes an extra table will be needed. There is a third party app named django-simple-history which handles it for you.

πŸ‘€Benbb96

0πŸ‘

Best option is the second one, in your first example it’s not a soft delete if your deleting it from the table – soft should be to modify the data in a minimal way. Leaving the row in place is the purpose of a soft-delete, this has the minimal effect on the data and will retain all attributes such as primary key index value and any internals you cant see that the database might use.

Your first option is far less succinct as it means duplicating data structures. A common approach is to add a "deleted_at" column (default to NULL), this positively identifies the record state.

πŸ‘€Web-Engineer

Leave a comment