Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
CREATE TABLE public.repositories(
id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
"url" VARCHAR(1024) NOT NULL UNIQUE,
"segmentId" UUID NOT NULL REFERENCES "segments"(id) ON DELETE CASCADE,
"gitIntegrationId" UUID NOT NULL REFERENCES public."integrations" (id) ON DELETE CASCADE,
"sourceIntegrationId" UUID NOT NULL REFERENCES public."integrations" (id) ON DELETE CASCADE,
"insightsProjectId" UUID NOT NULL REFERENCES "insightsProjects"(id) ON DELETE CASCADE,
"archived" BOOLEAN NOT NULL DEFAULT FALSE,
"forkedFrom" VARCHAR(1024) DEFAULT NULL,
"excluded" BOOLEAN NOT NULL DEFAULT FALSE,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
"deletedAt" TIMESTAMP WITH TIME ZONE,
"lastArchivedCheckAt" TIMESTAMP WITH TIME ZONE DEFAULT NULL
);

CREATE INDEX ix_repositories_segmentId
ON repositories ("segmentId")
WHERE "deletedAt" IS NULL;

CREATE INDEX ix_repositories_sourceIntegrationId
ON repositories ("sourceIntegrationId")
WHERE "deletedAt" IS NULL;

CREATE INDEX ix_repositories_insightsProjectId
ON repositories ("insightsProjectId")
WHERE "deletedAt" IS NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
CREATE TABLE git."repositoryProcessing" (
"id" UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),

"repositoryId" UUID NOT NULL UNIQUE REFERENCES public.repositories ("id") ON DELETE CASCADE,
"branch" VARCHAR(255) DEFAULT NULL,
"state" VARCHAR(50) NOT NULL DEFAULT 'pending',
"priority" INTEGER NOT NULL DEFAULT 1,
"lockedAt" TIMESTAMP WITH TIME ZONE DEFAULT NULL,
"lastProcessedAt" TIMESTAMP WITH TIME ZONE DEFAULT NULL,
"lastProcessedCommit" VARCHAR(64) DEFAULT NULL,
"maintainerFile" VARCHAR(255) DEFAULT NULL,
"lastMaintainerRunAt" TIMESTAMP WITH TIME ZONE DEFAULT NULL,
"stuckRequiresReOnboard" BOOLEAN NOT NULL DEFAULT FALSE,
"reOnboardingCount" INTEGER NOT NULL DEFAULT 0
);

CREATE INDEX "ix_git_repositoryProcessing_onboarding_acquisition"
ON git."repositoryProcessing" ("state", "lockedAt", "priority", "createdAt")
WHERE "state" = 'pending' AND "lockedAt" IS NULL;

CREATE INDEX "ix_git_repositoryProcessing_recurrent_acquisition"
ON git."repositoryProcessing" ("state", "lockedAt", "lastProcessedAt", "priority")
WHERE "lockedAt" IS NULL;

CREATE INDEX "ix_git_repositoryProcessing_active_onboarding_count"
ON git."repositoryProcessing" ("state")
WHERE "state" = 'processing' AND "lastProcessedCommit" IS NULL;