fix(db): ajouter 'cancelled' à la contrainte CHECK de index_jobs.status
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 <noreply@anthropic.com>
This commit is contained in:
@@ -85,18 +85,14 @@ export function JobsList({ initialJobs, libraries, highlightJobId }: JobsListPro
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleCancel = async (id: string) => {
|
const handleCancel = async (id: string) => {
|
||||||
try {
|
const response = await fetch(`/api/jobs/${id}/cancel`, { method: "POST" });
|
||||||
const response = await fetch(`/api/jobs/${id}/cancel`, {
|
if (response.ok) {
|
||||||
method: "POST",
|
setJobs(jobs.map(job =>
|
||||||
});
|
job.id === id ? { ...job, status: "cancelled" } : job
|
||||||
|
));
|
||||||
if (response.ok) {
|
} else {
|
||||||
setJobs(jobs.map(job =>
|
const data = await response.json().catch(() => ({}));
|
||||||
job.id === id ? { ...job, status: "cancelled" } : job
|
console.error("Failed to cancel job:", data?.error ?? response.status);
|
||||||
));
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to cancel job:", error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
4
infra/migrations/0017_add_cancelled_status.sql
Normal file
4
infra/migrations/0017_add_cancelled_status.sql
Normal file
@@ -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'));
|
||||||
Reference in New Issue
Block a user