36 lines
1.2 KiB
PL/PgSQL
36 lines
1.2 KiB
PL/PgSQL
-- T6 night queue / journal (runbook v2.0)
|
|
-- Schema: hub_core.agents.night_queue, night_journal
|
|
BEGIN;
|
|
|
|
CREATE TABLE IF NOT EXISTS hub_core.agents.night_queue (
|
|
id bigserial PRIMARY KEY,
|
|
dedup_key text NOT NULL UNIQUE,
|
|
task_id text,
|
|
class text NOT NULL,
|
|
payload jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
status text NOT NULL DEFAULT 'pending'
|
|
CHECK (status IN ('pending','running','done','blocked','failed')),
|
|
budget_rub numeric(10,4) NOT NULL CHECK (budget_rub > 0),
|
|
approved_by text,
|
|
approved_at timestamptz,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
started_at timestamptz,
|
|
finished_at timestamptz
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS hub_core.agents.night_journal (
|
|
id bigserial PRIMARY KEY,
|
|
queue_id bigint,
|
|
task_id text,
|
|
class text NOT NULL,
|
|
status text NOT NULL,
|
|
tokens bigint DEFAULT 0,
|
|
cost_rub numeric(10,4) DEFAULT 0,
|
|
write_actions integer DEFAULT 0,
|
|
secret_reads integer DEFAULT 0,
|
|
error text,
|
|
created_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
|
|
COMMIT;
|