Skip to content

Commit e43b410

Browse files
authored
feat: init new standard repositories tables [CM-864] (#3719)
1 parent c44a45f commit e43b410

4 files changed

Lines changed: 56 additions & 0 deletions

backend/src/database/migrations/U1766661879__createRepositoriesTable.sql

Whitespace-only changes.

backend/src/database/migrations/U1766669430__createGitRepositoryProcessingTable.sql

Whitespace-only changes.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
CREATE TABLE public.repositories(
2+
id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
3+
"url" VARCHAR(1024) NOT NULL UNIQUE,
4+
"segmentId" UUID NOT NULL REFERENCES "segments"(id) ON DELETE CASCADE,
5+
"gitIntegrationId" UUID NOT NULL REFERENCES public."integrations" (id) ON DELETE CASCADE,
6+
"sourceIntegrationId" UUID NOT NULL REFERENCES public."integrations" (id) ON DELETE CASCADE,
7+
"insightsProjectId" UUID NOT NULL REFERENCES "insightsProjects"(id) ON DELETE CASCADE,
8+
"archived" BOOLEAN NOT NULL DEFAULT FALSE,
9+
"forkedFrom" VARCHAR(1024) DEFAULT NULL,
10+
"excluded" BOOLEAN NOT NULL DEFAULT FALSE,
11+
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
12+
"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
13+
"deletedAt" TIMESTAMP WITH TIME ZONE,
14+
"lastArchivedCheckAt" TIMESTAMP WITH TIME ZONE DEFAULT NULL
15+
);
16+
17+
CREATE INDEX ix_repositories_segmentId
18+
ON repositories ("segmentId")
19+
WHERE "deletedAt" IS NULL;
20+
21+
CREATE INDEX ix_repositories_sourceIntegrationId
22+
ON repositories ("sourceIntegrationId")
23+
WHERE "deletedAt" IS NULL;
24+
25+
CREATE INDEX ix_repositories_insightsProjectId
26+
ON repositories ("insightsProjectId")
27+
WHERE "deletedAt" IS NULL;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
CREATE TABLE git."repositoryProcessing" (
2+
"id" UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
3+
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
4+
"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
5+
6+
"repositoryId" UUID NOT NULL UNIQUE REFERENCES public.repositories ("id") ON DELETE CASCADE,
7+
"branch" VARCHAR(255) DEFAULT NULL,
8+
"state" VARCHAR(50) NOT NULL DEFAULT 'pending',
9+
"priority" INTEGER NOT NULL DEFAULT 1,
10+
"lockedAt" TIMESTAMP WITH TIME ZONE DEFAULT NULL,
11+
"lastProcessedAt" TIMESTAMP WITH TIME ZONE DEFAULT NULL,
12+
"lastProcessedCommit" VARCHAR(64) DEFAULT NULL,
13+
"maintainerFile" VARCHAR(255) DEFAULT NULL,
14+
"lastMaintainerRunAt" TIMESTAMP WITH TIME ZONE DEFAULT NULL,
15+
"stuckRequiresReOnboard" BOOLEAN NOT NULL DEFAULT FALSE,
16+
"reOnboardingCount" INTEGER NOT NULL DEFAULT 0
17+
);
18+
19+
CREATE INDEX "ix_git_repositoryProcessing_onboarding_acquisition"
20+
ON git."repositoryProcessing" ("state", "lockedAt", "priority", "createdAt")
21+
WHERE "state" = 'pending' AND "lockedAt" IS NULL;
22+
23+
CREATE INDEX "ix_git_repositoryProcessing_recurrent_acquisition"
24+
ON git."repositoryProcessing" ("state", "lockedAt", "lastProcessedAt", "priority")
25+
WHERE "lockedAt" IS NULL;
26+
27+
CREATE INDEX "ix_git_repositoryProcessing_active_onboarding_count"
28+
ON git."repositoryProcessing" ("state")
29+
WHERE "state" = 'processing' AND "lastProcessedCommit" IS NULL;

0 commit comments

Comments
 (0)