I'm using DB::transaction
and SoftDeletes
.
For those unfamiliar with Laravel the SoftDelete
functionality of Laravel abstracts away the setting / querying of rows in the database. When a record is deleted the field deleted_at
is given a timestamp otherwise this field is null
. This field is then used on querying to only get non deleted rows.
Currently I have a script that runs every day that deletes all the soft deleted entries that are older than 7 days.
This is where my question/problem is. What if my DB::transaction spanned for let's say 2 minutes and add the end writes to Table A and Table B so that the entries in both tables have a different timestamp.
I can picture a scenario where when the cleanup script executes it could delete HALF of the entry records.
My question then is
Thanks elite123, well the biggest problem is the deleted_at field by the soft delete is set for me automatically so I don't see how to manually override it so it takes my value.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community