From dd6b4943f979caace492c2a1fd60cf208533221b Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 24 Oct 2023 16:59:36 +0800 Subject: [PATCH] refactor: add migration --- .../20231024085853_add_monitor_status/migration.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 prisma/migrations/20231024085853_add_monitor_status/migration.sql diff --git a/prisma/migrations/20231024085853_add_monitor_status/migration.sql b/prisma/migrations/20231024085853_add_monitor_status/migration.sql new file mode 100644 index 0000000..14bc3a0 --- /dev/null +++ b/prisma/migrations/20231024085853_add_monitor_status/migration.sql @@ -0,0 +1,13 @@ +-- CreateTable +CREATE TABLE "MonitorStatus" ( + "monitorId" VARCHAR(30) NOT NULL, + "statusName" VARCHAR(50) NOT NULL, + "payload" JSON NOT NULL, + "createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(6) NOT NULL, + + CONSTRAINT "MonitorStatus_pkey" PRIMARY KEY ("monitorId","statusName") +); + +-- AddForeignKey +ALTER TABLE "MonitorStatus" ADD CONSTRAINT "MonitorStatus_monitorId_fkey" FOREIGN KEY ("monitorId") REFERENCES "Monitor"("id") ON DELETE CASCADE ON UPDATE CASCADE;