|
| 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