Files
sorsfonalak/crates/db/migrations/0010_prompt_previews.sql
T
fecoandClaude Opus 5.5 b77dafdb26
CI / test (push) Successful in 46s
CI / build (push) Successful in 4m16s
CI / deploy (push) Skipped
Try draft prompts on own charts before saving
Under each prompt on /admin/promptok, "Kipróbálás" writes the summary or
detailed analysis with the text in the editor (saved or not) on one of the
admin's own charts. Test runs live in prompt_previews: never shown with the
chart, not cached, no credits, one attempt, at most three open per admin,
removed after 30 days. The worker writes them when no analysis is due. The
result shows the model, tokens, cost and time, and the draft can be loaded back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-17 14:41:12 +00:00

30 lines
1.3 KiB
SQL

-- Test runs of an edited (not yet saved) system prompt on one of the admin's
-- charts. Kept apart from analyses: never shown to users, never cached, no
-- credits, one attempt. Removed after 30 days by the cleanup job.
CREATE TABLE prompt_previews (
id uuid PRIMARY KEY,
kind text NOT NULL CHECK (kind IN ('summary', 'natal')),
chart_id uuid NOT NULL REFERENCES charts ON DELETE CASCADE,
language text NOT NULL,
model text NOT NULL,
system text NOT NULL CHECK (length(system) BETWEEN 1 AND 50000),
status text NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'running', 'done', 'failed')),
content jsonb,
error text,
model_used text,
input_tokens integer,
output_tokens integer,
cost_usd double precision,
created_by uuid NOT NULL REFERENCES users ON DELETE CASCADE,
created_at timestamptz NOT NULL DEFAULT now(),
started_at timestamptz,
completed_at timestamptz
);
CREATE INDEX prompt_previews_pending_idx ON prompt_previews (created_at) WHERE status = 'pending';
-- Wakes the analysis worker, like a new analysis.
CREATE TRIGGER prompt_previews_notify
AFTER INSERT ON prompt_previews
FOR EACH STATEMENT EXECUTE FUNCTION notify_analyses();