Initial TriggerHttpEndpoint migrations

This commit is contained in:
Matt Aitken
2023-10-24 13:26:00 +01:00
parent 108d34843e
commit 734624371b
3 changed files with 86 additions and 7 deletions
@@ -0,0 +1,29 @@
-- CreateTable
CREATE TABLE "TriggerHttpEndpoint" (
"id" TEXT NOT NULL,
"key" TEXT NOT NULL,
"active" BOOLEAN NOT NULL DEFAULT true,
"immediateResponseFilter" JSONB,
"title" TEXT,
"icon" TEXT,
"properties" JSONB,
"secretReferenceId" TEXT NOT NULL,
"environmentId" TEXT NOT NULL,
"projectId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "TriggerHttpEndpoint_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "TriggerHttpEndpoint_key_environmentId_key" ON "TriggerHttpEndpoint"("key", "environmentId");
-- AddForeignKey
ALTER TABLE "TriggerHttpEndpoint" ADD CONSTRAINT "TriggerHttpEndpoint_secretReferenceId_fkey" FOREIGN KEY ("secretReferenceId") REFERENCES "SecretReference"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "TriggerHttpEndpoint" ADD CONSTRAINT "TriggerHttpEndpoint_environmentId_fkey" FOREIGN KEY ("environmentId") REFERENCES "RuntimeEnvironment"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "TriggerHttpEndpoint" ADD CONSTRAINT "TriggerHttpEndpoint_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,19 @@
/*
Warnings:
- You are about to drop the column `environmentId` on the `TriggerHttpEndpoint` table. All the data in the column will be lost.
- A unique constraint covering the columns `[key,projectId]` on the table `TriggerHttpEndpoint` will be added. If there are existing duplicate values, this will fail.
*/
-- DropForeignKey
ALTER TABLE "TriggerHttpEndpoint" DROP CONSTRAINT "TriggerHttpEndpoint_environmentId_fkey";
-- DropIndex
DROP INDEX "TriggerHttpEndpoint_key_environmentId_key";
-- AlterTable
ALTER TABLE "TriggerHttpEndpoint" DROP COLUMN "environmentId",
ALTER COLUMN "active" SET DEFAULT false;
-- CreateIndex
CREATE UNIQUE INDEX "TriggerHttpEndpoint_key_projectId_key" ON "TriggerHttpEndpoint"("key", "projectId");
+38 -7
View File
@@ -292,6 +292,9 @@ model RuntimeEnvironment {
type RuntimeEnvironmentType @default(DEVELOPMENT)
///A memorable code for the environment
// shortcode String?
autoEnableInternalSources Boolean @default(true)
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
@@ -318,6 +321,7 @@ model RuntimeEnvironment {
eventDispatchers EventDispatcher[]
scheduleSources ScheduleSource[]
ExternalAccount ExternalAccount[]
// @@unique([projectId, shortcode])
@@unique([projectId, slug, orgMemberId])
}
@@ -340,13 +344,14 @@ model Project {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
environments RuntimeEnvironment[]
endpoints Endpoint[]
jobs Job[]
jobVersion JobVersion[]
events EventRecord[]
runs JobRun[]
sources TriggerSource[]
environments RuntimeEnvironment[]
endpoints Endpoint[]
jobs Job[]
jobVersion JobVersion[]
events EventRecord[]
runs JobRun[]
sources TriggerSource[]
httpEndpoints TriggerHttpEndpoint[]
}
model Endpoint {
@@ -925,6 +930,7 @@ model SecretReference {
connections IntegrationConnection[]
integrations Integration[]
triggerSources TriggerSource[]
httpEndpoints TriggerHttpEndpoint[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@ -1099,6 +1105,31 @@ model ScheduleSource {
@@unique([key, environmentId])
}
model TriggerHttpEndpoint {
id String @id @default(cuid())
key String
active Boolean @default(false)
/// If this is set, requests will be tested against the filter and we'll call the user's server immediately
immediateResponseFilter Json?
title String?
icon String?
properties Json?
secretReference SecretReference @relation(fields: [secretReferenceId], references: [id], onDelete: Cascade, onUpdate: Cascade)
secretReferenceId String
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade, onUpdate: Cascade)
projectId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([key, projectId])
}
model MissingConnection {
id String @id @default(cuid())