Skip to content

Commit aba0f8c

Browse files
committed
Create migration for figma file webhooks (#259)
1 parent bf0acd7 commit aba0f8c

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-- CreateEnum
2+
CREATE TYPE "jira_figma_webhook_event_type" AS ENUM ('FILE_UPDATE', 'DEV_MODE_STATUS_UPDATE');
3+
4+
-- CreateTable
5+
CREATE TABLE "jira_figma_file_webhook" (
6+
"id" BIGSERIAL NOT NULL,
7+
"webhook_id" TEXT NOT NULL,
8+
"webhook_passcode" TEXT NOT NULL,
9+
"event_type" "jira_figma_webhook_event_type" NOT NULL,
10+
"file_key" TEXT NOT NULL,
11+
"creator_atlassian_user_id" TEXT NOT NULL,
12+
"connect_installation_id" BIGINT NOT NULL,
13+
14+
CONSTRAINT "jira_figma_file_webhook_pkey" PRIMARY KEY ("id")
15+
);
16+
17+
-- CreateIndex
18+
CREATE UNIQUE INDEX "jira_figma_file_webhook_webhook_id_key" ON "jira_figma_file_webhook"("webhook_id");
19+
20+
-- CreateIndex
21+
CREATE UNIQUE INDEX "jira_figma_file_webhook_file_key_event_type_connect_install_key" ON "jira_figma_file_webhook"("file_key", "event_type", "connect_installation_id");
22+
23+
-- AddForeignKey
24+
ALTER TABLE "jira_figma_file_webhook" ADD CONSTRAINT "jira_figma_file_webhook_connect_installation_id_fkey" FOREIGN KEY ("connect_installation_id") REFERENCES "jira_connect_installation"("id") ON DELETE CASCADE ON UPDATE NO ACTION;

prisma/schema.prisma

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ model ConnectInstallation {
1717
FigmaOAuth2UserCredentials FigmaOAuth2UserCredentials[]
1818
FigmaTeam FigmaTeam[]
1919
AssociatedFigmaDesign AssociatedFigmaDesign[]
20+
FigmaFileWebhook FigmaFileWebhook[]
2021
2122
@@map("jira_connect_installation")
2223
}
@@ -71,3 +72,25 @@ model FigmaTeam {
7172
@@unique([teamId, connectInstallationId])
7273
@@map("jira_figma_team")
7374
}
75+
76+
model FigmaFileWebhook {
77+
id BigInt @id @default(autoincrement())
78+
webhookId String @unique @map("webhook_id")
79+
webhookPasscode String @map("webhook_passcode")
80+
eventType WebhookEventType @map("event_type")
81+
fileKey String @map("file_key")
82+
creatorAtlassianUserId String @map("creator_atlassian_user_id") // Atlassian user ID of the Figma user that configured the webhook
83+
84+
connectInstallation ConnectInstallation @relation(fields: [connectInstallationId], references: [id], onDelete: Cascade, onUpdate: NoAction)
85+
connectInstallationId BigInt @map("connect_installation_id")
86+
87+
@@unique([fileKey, eventType, connectInstallationId])
88+
@@map("jira_figma_file_webhook")
89+
}
90+
91+
enum WebhookEventType {
92+
FILE_UPDATE
93+
DEV_MODE_STATUS_UPDATE
94+
95+
@@map("jira_figma_webhook_event_type")
96+
}

0 commit comments

Comments
 (0)