You've already forked agentic-coding-workflow
feat(jobs): migration 0005 + errs codes for jobs module
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE workspace_worktrees DROP COLUMN IF EXISTS prune_warning_at;
|
||||
DROP TABLE IF EXISTS jobs;
|
||||
@@ -0,0 +1,24 @@
|
||||
-- ============ jobs(DB-backed 事件型任务) ============
|
||||
CREATE TABLE jobs (
|
||||
id UUID PRIMARY KEY,
|
||||
type TEXT NOT NULL,
|
||||
payload JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
status TEXT NOT NULL DEFAULT 'pending',
|
||||
scheduled_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
attempts INT NOT NULL DEFAULT 0,
|
||||
max_attempts INT NOT NULL DEFAULT 5,
|
||||
leased_at TIMESTAMPTZ,
|
||||
leased_by TEXT,
|
||||
last_error TEXT,
|
||||
completed_at TIMESTAMPTZ,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
CONSTRAINT jobs_status_check CHECK (status IN ('pending','running','completed','dead'))
|
||||
);
|
||||
CREATE INDEX idx_jobs_pickup ON jobs(scheduled_at, status) WHERE status = 'pending';
|
||||
CREATE INDEX idx_jobs_lease ON jobs(leased_at) WHERE status = 'running';
|
||||
CREATE INDEX idx_jobs_purge ON jobs(completed_at) WHERE status IN ('completed', 'dead');
|
||||
|
||||
-- ============ ALTER workspace_worktrees: add prune_warning_at ============
|
||||
ALTER TABLE workspace_worktrees
|
||||
ADD COLUMN prune_warning_at TIMESTAMPTZ;
|
||||
Reference in New Issue
Block a user