mirror of https://github.com/buster-so/buster.git
Merge pull request #574 from buster-so/devin/BUS-1462-1753076609
feat: add GitHub integrations table for BUS-1462
This commit is contained in:
commit
6d148947c9
|
@ -0,0 +1,27 @@
|
||||||
|
CREATE TYPE "public"."github_integration_status_enum" AS ENUM('pending', 'active', 'suspended', 'revoked');--> statement-breakpoint
|
||||||
|
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) NOT NULL,
|
||||||
|
"app_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),
|
||||||
|
"repository_permissions" jsonb DEFAULT '{}'::jsonb,
|
||||||
|
"status" "github_integration_status_enum" DEFAULT 'pending' NOT NULL,
|
||||||
|
"installed_at" timestamp with time zone,
|
||||||
|
"last_used_at" timestamp with time zone,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"deleted_at" timestamp with time zone,
|
||||||
|
CONSTRAINT "github_integrations_token_vault_key_unique" UNIQUE("token_vault_key"),
|
||||||
|
CONSTRAINT "github_integrations_org_installation_key" UNIQUE("organization_id","installation_id")
|
||||||
|
);
|
||||||
|
--> 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 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);--> statement-breakpoint
|
||||||
|
CREATE INDEX "idx_github_integrations_github_org_id" ON "github_integrations" USING btree ("github_org_id" text_ops);
|
|
@ -589,6 +589,13 @@
|
||||||
"when": 1752866508221,
|
"when": 1752866508221,
|
||||||
"tag": "0083_wild_thor_girl",
|
"tag": "0083_wild_thor_girl",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 84,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1753076918000,
|
||||||
|
"tag": "0084_github_integrations",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,13 @@ export const slackSharingPermissionEnum = pgEnum('slack_sharing_permission_enum'
|
||||||
'noSharing',
|
'noSharing',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
export const githubIntegrationStatusEnum = pgEnum('github_integration_status_enum', [
|
||||||
|
'pending',
|
||||||
|
'active',
|
||||||
|
'suspended',
|
||||||
|
'revoked',
|
||||||
|
]);
|
||||||
|
|
||||||
export const workspaceSharingEnum = pgEnum('workspace_sharing_enum', [
|
export const workspaceSharingEnum = pgEnum('workspace_sharing_enum', [
|
||||||
'none',
|
'none',
|
||||||
'can_view',
|
'can_view',
|
||||||
|
@ -1942,6 +1949,65 @@ export const slackIntegrations = pgTable(
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// GitHub integrations table
|
||||||
|
export const githubIntegrations = pgTable(
|
||||||
|
'github_integrations',
|
||||||
|
{
|
||||||
|
id: uuid().defaultRandom().primaryKey().notNull(),
|
||||||
|
organizationId: uuid('organization_id').notNull(),
|
||||||
|
userId: uuid('user_id').notNull(),
|
||||||
|
|
||||||
|
installationId: varchar('installation_id', { length: 255 }).notNull(),
|
||||||
|
appId: varchar('app_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(),
|
||||||
|
webhookSecretVaultKey: varchar('webhook_secret_vault_key', { length: 255 }),
|
||||||
|
|
||||||
|
repositoryPermissions: jsonb('repository_permissions').default({}),
|
||||||
|
|
||||||
|
status: githubIntegrationStatusEnum().default('pending').notNull(),
|
||||||
|
installedAt: timestamp('installed_at', { withTimezone: true, mode: 'string' }),
|
||||||
|
lastUsedAt: timestamp('last_used_at', { withTimezone: true, mode: 'string' }),
|
||||||
|
|
||||||
|
// Timestamps
|
||||||
|
createdAt: timestamp('created_at', { withTimezone: true, mode: 'string' })
|
||||||
|
.defaultNow()
|
||||||
|
.notNull(),
|
||||||
|
updatedAt: timestamp('updated_at', { withTimezone: true, mode: 'string' })
|
||||||
|
.defaultNow()
|
||||||
|
.notNull(),
|
||||||
|
deletedAt: timestamp('deleted_at', { withTimezone: true, mode: 'string' }),
|
||||||
|
},
|
||||||
|
(table) => [
|
||||||
|
foreignKey({
|
||||||
|
columns: [table.organizationId],
|
||||||
|
foreignColumns: [organizations.id],
|
||||||
|
name: 'github_integrations_organization_id_fkey',
|
||||||
|
}).onDelete('cascade'),
|
||||||
|
foreignKey({
|
||||||
|
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',
|
||||||
|
table.organizationId.asc().nullsLast().op('uuid_ops')
|
||||||
|
),
|
||||||
|
index('idx_github_integrations_installation_id').using(
|
||||||
|
'btree',
|
||||||
|
table.installationId.asc().nullsLast().op('text_ops')
|
||||||
|
),
|
||||||
|
index('idx_github_integrations_github_org_id').using(
|
||||||
|
'btree',
|
||||||
|
table.githubOrgId.asc().nullsLast().op('text_ops')
|
||||||
|
),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
// Slack message tracking table (optional)
|
// Slack message tracking table (optional)
|
||||||
export const slackMessageTracking = pgTable(
|
export const slackMessageTracking = pgTable(
|
||||||
'slack_message_tracking',
|
'slack_message_tracking',
|
||||||
|
|
Loading…
Reference in New Issue