-- Phase 7: Quality & Validation tables
-- quality_gates: registered quality gate configurations
-- validation_results: recorded pass/fail results from gate checks

CREATE TABLE IF NOT EXISTS quality_gates (
    id TEXT PRIMARY KEY,
    name TEXT NOT NULL,
    gate_type TEXT NOT NULL,
    config JSON NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS validation_results (
    id TEXT PRIMARY KEY,
    run_id TEXT NOT NULL,
    gate_id TEXT NOT NULL,
    artifact_id TEXT,
    status TEXT NOT NULL,
    score REAL,
    diagnostics JSON,
    validated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX IF NOT EXISTS idx_validations_run ON validation_results(run_id);
CREATE INDEX IF NOT EXISTS idx_validations_artifact ON validation_results(artifact_id);
