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 10 seconds 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
- would a DB::transaction give the same timestamp to all the records?
- if not how can I remedy this problem?