git-subtree-dir: services/core git-subtree-mainline:6f5e3a119fgit-subtree-split:6fdbc73753
23 lines
761 B
SQL
23 lines
761 B
SQL
-- +goose Up
|
|
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
|
|
|
CREATE TABLE IF NOT EXISTS tasks (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
title text NOT NULL,
|
|
source text NOT NULL,
|
|
status text NOT NULL DEFAULT 'pending',
|
|
payload jsonb NOT NULL DEFAULT '{}',
|
|
result jsonb NOT NULL DEFAULT '{}',
|
|
error text NULL,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
CONSTRAINT tasks_status_check CHECK (
|
|
status IN ('pending', 'queued', 'running', 'completed', 'failed', 'canceled')
|
|
)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS tasks_status_idx ON tasks (status);
|
|
CREATE INDEX IF NOT EXISTS tasks_created_at_idx ON tasks (created_at DESC);
|
|
|
|
-- +goose Down
|
|
DROP TABLE IF EXISTS tasks;
|