Skip to content

Commit 27dd596

Browse files
committed
feat: add migrations (CM-950) (#3835)
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent 21174b8 commit 27dd596

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
DROP INDEX IF EXISTS "ix_evaluatedProjects_onboarded";
2+
DROP INDEX IF EXISTS "ix_evaluatedProjects_evaluationScore";
3+
DROP INDEX IF EXISTS "ix_evaluatedProjects_evaluationStatus";
4+
DROP INDEX IF EXISTS "uix_evaluatedProjects_projectCatalogId";
5+
DROP TABLE IF EXISTS "evaluatedProjects";
6+
7+
DROP INDEX IF EXISTS "ix_projectCatalog_syncedAt";
8+
DROP INDEX IF EXISTS "ix_projectCatalog_criticalityScore";
9+
DROP INDEX IF EXISTS "uix_projectCatalog_repoUrl";
10+
DROP TABLE IF EXISTS "projectCatalog";
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
-- Project Catalog: candidate projects discovered from OSSF Criticality Score and other sources
2+
CREATE TABLE IF NOT EXISTS "projectCatalog" (
3+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
4+
"projectSlug" VARCHAR(255) NOT NULL,
5+
"repoName" VARCHAR(255) NOT NULL,
6+
"repoUrl" VARCHAR(1024) NOT NULL,
7+
"criticalityScore" DOUBLE PRECISION,
8+
"syncedAt" TIMESTAMP WITH TIME ZONE DEFAULT NULL,
9+
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
10+
"updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
11+
);
12+
13+
CREATE UNIQUE INDEX "uix_projectCatalog_repoUrl" ON "projectCatalog" ("repoUrl");
14+
CREATE INDEX "ix_projectCatalog_criticalityScore" ON "projectCatalog" ("criticalityScore" DESC NULLS LAST);
15+
CREATE INDEX "ix_projectCatalog_syncedAt" ON "projectCatalog" ("syncedAt");
16+
17+
-- Evaluated Projects: AI evaluation results linked to catalog entries
18+
CREATE TABLE IF NOT EXISTS "evaluatedProjects" (
19+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
20+
"projectCatalogId" UUID NOT NULL REFERENCES "projectCatalog"(id) ON DELETE CASCADE,
21+
"evaluationStatus" VARCHAR(50) NOT NULL DEFAULT 'pending',
22+
"evaluationScore" DOUBLE PRECISION,
23+
"evaluation" JSONB,
24+
"evaluationReason" TEXT,
25+
"evaluatedAt" TIMESTAMP WITH TIME ZONE,
26+
"starsCount" INTEGER,
27+
"forksCount" INTEGER,
28+
"commitsCount" INTEGER,
29+
"pullRequestsCount" INTEGER,
30+
"issuesCount" INTEGER,
31+
"onboarded" BOOLEAN NOT NULL DEFAULT FALSE,
32+
"onboardedAt" TIMESTAMP WITH TIME ZONE,
33+
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
34+
"updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
35+
);
36+
37+
CREATE UNIQUE INDEX "uix_evaluatedProjects_projectCatalogId" ON "evaluatedProjects" ("projectCatalogId");
38+
CREATE INDEX "ix_evaluatedProjects_evaluationStatus" ON "evaluatedProjects" ("evaluationStatus");
39+
CREATE INDEX "ix_evaluatedProjects_evaluationScore" ON "evaluatedProjects" ("evaluationScore" DESC NULLS LAST);
40+
CREATE INDEX "ix_evaluatedProjects_onboarded" ON "evaluatedProjects" ("onboarded");

0 commit comments

Comments
 (0)