Soft Deletes

Soft deletes are a common technique in software development and you'll see that some frameworks have soft delete functionality built in.

What it means is that you don't really delete the record from the database but you populate a datetime field (usually called deleted_at or similar) to say when the record was 'deleted'.

Then if that field has a non-null value it can be considered deleted.

We're doing the same thing here but let's think about the domain and the terminology which would be more suited to reservations. Instead of deleting a record, we shall add a timestamp to a cancelled_at field. Then any reservation with a cancelled_at can be considered cancelled.

Let's go!

Branch: https://github.com/GaryClarke/php-api-pro/tree/53-soft-deletes

Complete and Continue  
Discussion

4 comments