CREATE TABLE IF NOT EXISTS repo_health_scores (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
repository_id UUID NOT NULL REFERENCES repositories(id) ON DELETE CASCADE,
score INTEGER NOT NULL,
grade TEXT NOT NULL,
security_score INTEGER NOT NULL,
gates_score INTEGER NOT NULL,
ai_review_score INTEGER NOT NULL,
dependencies_score INTEGER NOT NULL,
code_quality_score INTEGER NOT NULL,
recommendations JSONB NOT NULL DEFAULT '[]',
issues_found JSONB NOT NULL DEFAULT '[]',
computed_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS repo_health_scores_repo ON repo_health_scores(repository_id);
CREATE INDEX IF NOT EXISTS repo_health_scores_computed ON repo_health_scores(computed_at DESC);
|