CREATE TABLE IF NOT EXISTS translations (
    id SERIAL PRIMARY KEY,
    source_text TEXT NOT NULL,
    translated_text TEXT NOT NULL,
    raw_output TEXT,
    model_name VARCHAR(100) NOT NULL,
    prompt TEXT NOT NULL,
    prompt_id INT,
    created_at TIMESTAMP NOT NULL DEFAULT NOW()
);

CREATE TABLE IF NOT EXISTS golden_examples (
    id SERIAL PRIMARY KEY,
    source_text TEXT NOT NULL,       -- китайский
    reference_text TEXT NOT NULL,    -- идеальный русский перевод
    domain VARCHAR(50) DEFAULT 'tech',
    description TEXT,
    created_at TIMESTAMP NOT NULL DEFAULT NOW(),
    created_by VARCHAR(100)
);

CREATE TABLE IF NOT EXISTS prompt_runs (
    id SERIAL PRIMARY KEY,
    prompt_id INT NOT NULL REFERENCES prompts(id),
    model_name VARCHAR(100) NOT NULL,
    golden_example_id INT NOT NULL REFERENCES golden_examples(id),

    source_text TEXT NOT NULL,
    reference_text TEXT NOT NULL,
    model_output TEXT NOT NULL,

    llm_score NUMERIC,               -- оценка LLM-оценщика (0..10)
    bleu_score NUMERIC,
    other_metrics JSONB,

    created_at TIMESTAMP NOT NULL DEFAULT NOW()
);