Skip to content

Commit 6b311cc

Browse files
committed
Save account handle and repo default branch on install
1 parent 114892f commit 6b311cc

3 files changed

Lines changed: 17 additions & 62 deletions

File tree

apps/webapp/app/services/gitHub.server.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ export async function linkGitHubAppInstallation(
3939
organizationId,
4040
targetId: installation.target_id,
4141
targetType: installation.target_type,
42+
accountHandle: installation.account
43+
? "login" in installation.account
44+
? installation.account.login
45+
: "slug" in installation.account
46+
? installation.account.slug
47+
: "-"
48+
: "-",
4249
permissions: installation.permissions,
4350
repositorySelection,
4451
repositories: {
@@ -76,5 +83,6 @@ async function fetchInstallationRepositories(octokit: Octokit, installationId: n
7683
fullName: repo.full_name,
7784
htmlUrl: repo.html_url,
7885
private: repo.private,
86+
defaultBranch: repo.default_branch,
7987
}));
8088
}
Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,11 @@
1-
-- CreateEnum
21
CREATE TYPE "public"."GithubRepositorySelection" AS ENUM ('ALL', 'SELECTED');
32

4-
-- DropIndex
5-
DROP INDEX "public"."SecretStore_key_idx";
6-
7-
-- DropIndex
8-
DROP INDEX "public"."TaskRun_runtimeEnvironmentId_createdAt_idx";
9-
10-
-- DropIndex
11-
DROP INDEX "public"."TaskRun_runtimeEnvironmentId_id_idx";
12-
13-
-- AlterTable
14-
ALTER TABLE "public"."_BackgroundWorkerToBackgroundWorkerFile" ADD CONSTRAINT "_BackgroundWorkerToBackgroundWorkerFile_AB_pkey" PRIMARY KEY ("A", "B");
15-
16-
-- DropIndex
17-
DROP INDEX "public"."_BackgroundWorkerToBackgroundWorkerFile_AB_unique";
18-
19-
-- AlterTable
20-
ALTER TABLE "public"."_BackgroundWorkerToTaskQueue" ADD CONSTRAINT "_BackgroundWorkerToTaskQueue_AB_pkey" PRIMARY KEY ("A", "B");
21-
22-
-- DropIndex
23-
DROP INDEX "public"."_BackgroundWorkerToTaskQueue_AB_unique";
24-
25-
-- AlterTable
26-
ALTER TABLE "public"."_TaskRunToTaskRunTag" ADD CONSTRAINT "_TaskRunToTaskRunTag_AB_pkey" PRIMARY KEY ("A", "B");
27-
28-
-- DropIndex
29-
DROP INDEX "public"."_TaskRunToTaskRunTag_AB_unique";
30-
31-
-- AlterTable
32-
ALTER TABLE "public"."_WaitpointRunConnections" ADD CONSTRAINT "_WaitpointRunConnections_AB_pkey" PRIMARY KEY ("A", "B");
33-
34-
-- DropIndex
35-
DROP INDEX "public"."_WaitpointRunConnections_AB_unique";
36-
37-
-- AlterTable
38-
ALTER TABLE "public"."_completedWaitpoints" ADD CONSTRAINT "_completedWaitpoints_AB_pkey" PRIMARY KEY ("A", "B");
39-
40-
-- DropIndex
41-
DROP INDEX "public"."_completedWaitpoints_AB_unique";
42-
43-
-- CreateTable
443
CREATE TABLE "public"."GithubAppInstallation" (
454
"id" TEXT NOT NULL,
465
"appInstallationId" INTEGER NOT NULL,
476
"targetId" INTEGER NOT NULL,
487
"targetType" TEXT NOT NULL,
8+
"accountHandle" TEXT NOT NULL,
499
"permissions" JSONB,
5010
"repositorySelection" "public"."GithubRepositorySelection" NOT NULL,
5111
"installedBy" TEXT,
@@ -58,14 +18,14 @@ CREATE TABLE "public"."GithubAppInstallation" (
5818
CONSTRAINT "GithubAppInstallation_pkey" PRIMARY KEY ("id")
5919
);
6020

61-
-- CreateTable
6221
CREATE TABLE "public"."GithubRepository" (
6322
"id" TEXT NOT NULL,
6423
"githubId" INTEGER NOT NULL,
6524
"name" TEXT NOT NULL,
6625
"fullName" TEXT NOT NULL,
6726
"htmlUrl" TEXT NOT NULL,
6827
"private" BOOLEAN NOT NULL,
28+
"defaultBranch" TEXT NOT NULL,
6929
"removedAt" TIMESTAMP(3),
7030
"installationId" TEXT NOT NULL,
7131
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -74,29 +34,14 @@ CREATE TABLE "public"."GithubRepository" (
7434
CONSTRAINT "GithubRepository_pkey" PRIMARY KEY ("id")
7535
);
7636

77-
-- CreateIndex
7837
CREATE UNIQUE INDEX "GithubAppInstallation_appInstallationId_key" ON "public"."GithubAppInstallation"("appInstallationId");
7938

80-
-- CreateIndex
8139
CREATE INDEX "GithubAppInstallation_organizationId_idx" ON "public"."GithubAppInstallation"("organizationId");
8240

83-
-- CreateIndex
8441
CREATE INDEX "GithubRepository_installationId_idx" ON "public"."GithubRepository"("installationId");
8542

86-
-- CreateIndex
8743
CREATE UNIQUE INDEX "GithubRepository_installationId_githubId_key" ON "public"."GithubRepository"("installationId", "githubId");
8844

89-
-- CreateIndex
90-
CREATE INDEX "SecretStore_key_idx" ON "public"."SecretStore"("key" text_pattern_ops);
91-
92-
-- CreateIndex
93-
CREATE INDEX "TaskRun_runtimeEnvironmentId_id_idx" ON "public"."TaskRun"("runtimeEnvironmentId", "id" DESC);
94-
95-
-- CreateIndex
96-
CREATE INDEX "TaskRun_runtimeEnvironmentId_createdAt_idx" ON "public"."TaskRun"("runtimeEnvironmentId", "createdAt" DESC);
97-
98-
-- AddForeignKey
9945
ALTER TABLE "public"."GithubAppInstallation" ADD CONSTRAINT "GithubAppInstallation_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "public"."Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
10046

101-
-- AddForeignKey
10247
ALTER TABLE "public"."GithubRepository" ADD CONSTRAINT "GithubRepository_installationId_fkey" FOREIGN KEY ("installationId") REFERENCES "public"."GithubAppInstallation"("id") ON DELETE CASCADE ON UPDATE CASCADE;

internal-packages/database/prisma/schema.prisma

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,6 +2251,7 @@ model GithubAppInstallation {
22512251
appInstallationId Int @unique
22522252
targetId Int
22532253
targetType String
2254+
accountHandle String
22542255
permissions Json?
22552256
repositorySelection GithubRepositorySelection
22562257
installedBy String?
@@ -2271,11 +2272,12 @@ model GithubAppInstallation {
22712272
model GithubRepository {
22722273
id String @id @default(cuid())
22732274
2274-
githubId Int
2275-
name String
2276-
fullName String
2277-
htmlUrl String
2278-
private Boolean
2275+
githubId Int
2276+
name String
2277+
fullName String
2278+
htmlUrl String
2279+
private Boolean
2280+
defaultBranch String
22792281
22802282
removedAt DateTime?
22812283

0 commit comments

Comments
 (0)