mirror of https://github.com/buster-so/buster.git
fix: address PR review comments for GitHub integrations
- Make installationId and githubOrgId NOT NULL (required GitHub API fields) - Change user foreign key to ON DELETE SET NULL to prevent blocking user deletion - Add index on github_org_id for better query performance - Maintain unique constraint on organization_id + installation_id pair Addresses greptile-apps review comments on PR #574 Co-Authored-By: Dallin Bentley <dallinbentley98@gmail.com>
This commit is contained in:
parent
45749b881b
commit
9b9330982a
|
@ -3,9 +3,9 @@ CREATE TABLE "github_integrations" (
|
|||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"organization_id" uuid NOT NULL,
|
||||
"user_id" uuid NOT NULL,
|
||||
"installation_id" varchar(255),
|
||||
"installation_id" varchar(255) NOT NULL,
|
||||
"app_id" varchar(255),
|
||||
"github_org_id" varchar(255),
|
||||
"github_org_id" varchar(255) NOT NULL,
|
||||
"github_org_name" varchar(255),
|
||||
"token_vault_key" varchar(255),
|
||||
"webhook_secret_vault_key" varchar(255),
|
||||
|
@ -21,6 +21,7 @@ CREATE TABLE "github_integrations" (
|
|||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "github_integrations" ADD CONSTRAINT "github_integrations_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "github_integrations" ADD CONSTRAINT "github_integrations_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "github_integrations" ADD CONSTRAINT "github_integrations_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "idx_github_integrations_org_id" ON "github_integrations" USING btree ("organization_id" uuid_ops);--> statement-breakpoint
|
||||
CREATE INDEX "idx_github_integrations_installation_id" ON "github_integrations" USING btree ("installation_id" text_ops);
|
||||
CREATE INDEX "idx_github_integrations_installation_id" ON "github_integrations" USING btree ("installation_id" text_ops);--> statement-breakpoint
|
||||
CREATE INDEX "idx_github_integrations_github_org_id" ON "github_integrations" USING btree ("github_org_id" text_ops);
|
||||
|
|
|
@ -1957,10 +1957,10 @@ export const githubIntegrations = pgTable(
|
|||
organizationId: uuid('organization_id').notNull(),
|
||||
userId: uuid('user_id').notNull(),
|
||||
|
||||
installationId: varchar('installation_id', { length: 255 }),
|
||||
installationId: varchar('installation_id', { length: 255 }).notNull(),
|
||||
appId: varchar('app_id', { length: 255 }),
|
||||
|
||||
githubOrgId: varchar('github_org_id', { length: 255 }),
|
||||
githubOrgId: varchar('github_org_id', { length: 255 }).notNull(),
|
||||
githubOrgName: varchar('github_org_name', { length: 255 }),
|
||||
|
||||
tokenVaultKey: varchar('token_vault_key', { length: 255 }).unique(),
|
||||
|
@ -1991,7 +1991,7 @@ export const githubIntegrations = pgTable(
|
|||
columns: [table.userId],
|
||||
foreignColumns: [users.id],
|
||||
name: 'github_integrations_user_id_fkey',
|
||||
}),
|
||||
}).onDelete('set null'),
|
||||
unique('github_integrations_org_installation_key').on(table.organizationId, table.installationId),
|
||||
index('idx_github_integrations_org_id').using(
|
||||
'btree',
|
||||
|
@ -2001,6 +2001,10 @@ export const githubIntegrations = pgTable(
|
|||
'btree',
|
||||
table.installationId.asc().nullsLast().op('text_ops')
|
||||
),
|
||||
index('idx_github_integrations_github_org_id').using(
|
||||
'btree',
|
||||
table.githubOrgId.asc().nullsLast().op('text_ops')
|
||||
),
|
||||
]
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue