I have the following table (MySQL):
This line of code in my asset model (mainly called by asynchronous jobs):
$this->sites()->syncWithPivotValues($sites, ['is_current_site' => true]);
My problem is that when I do this line I keep getting duplicate constraint errors and I don't understand why. Any ideas?
The problem I am facing is the concurrency issue between jobs.
I used the WithoutOverlapping middleware (https://laravel.com /docs/9.x/queues#preventing-job-overlaps) to prevent concurrency problems on my jobs, and the effect is very good .