forked from mtusi2026/mtusi2026lab5
17 lines
694 B
SQL
17 lines
694 B
SQL
ALTER TABLE attachments DROP CONSTRAINT IF EXISTS attachments_status_check;
|
|
ALTER TABLE attachments
|
|
ADD CONSTRAINT attachments_status_check
|
|
CHECK (status IN ('queued', 'processing', 'ready', 'failed'));
|
|
|
|
CREATE TABLE IF NOT EXISTS jobs (
|
|
id UUID PRIMARY KEY,
|
|
attachment_id UUID NOT NULL REFERENCES attachments(id) ON DELETE CASCADE,
|
|
pipeline_version INTEGER NOT NULL DEFAULT 1,
|
|
attempt INTEGER NOT NULL DEFAULT 1,
|
|
status TEXT NOT NULL DEFAULT 'queued',
|
|
error_code TEXT,
|
|
lease_until TIMESTAMPTZ,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|
|
CREATE INDEX IF NOT EXISTS idx_jobs_status ON jobs(status); |