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) => {
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
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