Files
descrybe/apps/api/sql/schema/024_ai_prompts.sql
T

23 lines
907 B
SQL
Raw Normal View History

-- +goose Up
-- Per-company editable AI prompt templates (system + user) with {{variable}} placeholders.
-- Empty templates fall back to built-in defaults in apps/api/internal/aiprompts.
CREATE TABLE ai_prompt_templates (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
company_id UUID NOT NULL REFERENCES companies(id) ON DELETE CASCADE,
prompt_key TEXT NOT NULL
CHECK (prompt_key IN ('product_enhance', 'seo_meta', 'campaign_email')),
system_template TEXT NOT NULL DEFAULT '',
user_template TEXT NOT NULL DEFAULT '',
is_enabled BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
UNIQUE (company_id, prompt_key)
);
CREATE INDEX ai_prompt_templates_company_idx ON ai_prompt_templates (company_id);
-- +goose Down
DROP INDEX IF EXISTS ai_prompt_templates_company_idx;
DROP TABLE IF EXISTS ai_prompt_templates;