From 1c106a4ff2e6dcc273126a06a4c6d06d2bceac53 Mon Sep 17 00:00:00 2001 From: Froidefond Julien Date: Wed, 11 Mar 2026 15:58:03 +0100 Subject: [PATCH] =?UTF-8?q?fix(db):=20ajouter=20'cancelled'=20=C3=A0=20la?= =?UTF-8?q?=20contrainte=20CHECK=20de=20index=5Fjobs.status?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La contrainte index_jobs_status_check ne listait pas 'cancelled', ce qui causait une erreur 500 à chaque tentative d'annulation de job. Co-Authored-By: Claude Sonnet 4.6 --- apps/backoffice/app/components/JobsList.tsx | 20 ++++++++----------- .../migrations/0017_add_cancelled_status.sql | 4 ++++ 2 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 infra/migrations/0017_add_cancelled_status.sql diff --git a/apps/backoffice/app/components/JobsList.tsx b/apps/backoffice/app/components/JobsList.tsx index 1f8fb73..710d2e9 100644 --- a/apps/backoffice/app/components/JobsList.tsx +++ b/apps/backoffice/app/components/JobsList.tsx @@ -85,18 +85,14 @@ export function JobsList({ initialJobs, libraries, highlightJobId }: JobsListPro }, []); const handleCancel = async (id: string) => { - try { - const response = await fetch(`/api/jobs/${id}/cancel`, { - method: "POST", - }); - - if (response.ok) { - setJobs(jobs.map(job => - job.id === id ? { ...job, status: "cancelled" } : job - )); - } - } catch (error) { - console.error("Failed to cancel job:", error); + const response = await fetch(`/api/jobs/${id}/cancel`, { method: "POST" }); + if (response.ok) { + setJobs(jobs.map(job => + job.id === id ? { ...job, status: "cancelled" } : job + )); + } else { + const data = await response.json().catch(() => ({})); + console.error("Failed to cancel job:", data?.error ?? response.status); } }; diff --git a/infra/migrations/0017_add_cancelled_status.sql b/infra/migrations/0017_add_cancelled_status.sql new file mode 100644 index 0000000..c56ee36 --- /dev/null +++ b/infra/migrations/0017_add_cancelled_status.sql @@ -0,0 +1,4 @@ +ALTER TABLE index_jobs + DROP CONSTRAINT IF EXISTS index_jobs_status_check, + ADD CONSTRAINT index_jobs_status_check + CHECK (status IN ('pending', 'running', 'generating_thumbnails', 'success', 'failed', 'cancelled'));