-- Migration 008: Regression test run history
-- Stores results of regression test runs for trend analysis.

CREATE TABLE IF NOT EXISTS regression_runs (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    run_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    status VARCHAR(20) NOT NULL,  -- 'pass', 'fail', 'error'
    total INT NOT NULL DEFAULT 0,
    passed INT NOT NULL DEFAULT 0,
    failed INT NOT NULL DEFAULT 0,
    errors INT NOT NULL DEFAULT 0,
    duration_ms INT,
    results JSONB NOT NULL DEFAULT '[]',
    triggered_by VARCHAR(50) DEFAULT 'manual'  -- 'manual', 'script', 'ci'
);

CREATE INDEX IF NOT EXISTS idx_regression_runs_run_at
    ON regression_runs (run_at DESC);
