mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-22 01:21:07 +00:00
Fix IntegrityError when creating periodic tasks
Change PeriodicTask.objects.get_or_create() to PeriodicTask.objects.update_or_create(). This change prevents a potential IntegrityError when creating a periodic task due to duplicate primary key. By using update_or_create, if the record already exists, it will be updated instead of attempting to insert a new record with the same primary key, ensuring the process completes without error.
This commit is contained in:
parent
13381b9b4d
commit
6143aa66e3
1 changed files with 1 additions and 1 deletions
|
@ -83,7 +83,7 @@ class Dashboard(View):
|
|||
schedule, _ = IntervalSchedule.objects.get_or_create(
|
||||
**schedule_form.cleaned_data
|
||||
)
|
||||
PeriodicTask.objects.get_or_create(
|
||||
PeriodicTask.objects.update_or_create(
|
||||
interval=schedule,
|
||||
name="check-for-updates",
|
||||
task="bookwyrm.models.site.check_for_updates_task",
|
||||
|
|
Loading…
Reference in a new issue