From c31a231495859ad4d4efe4e63b2d0cc73a9d67c3 Mon Sep 17 00:00:00 2001 From: khavinshankar Date: Fri, 25 Aug 2023 20:11:20 +0530 Subject: [PATCH] resolve conflicts in prisma schema migrations --- .../migration.sql | 21 ++++++++ .../20230824071303_add_bed/migration.sql | 44 --------------- .../migration.sql | 54 +++++++++++++++++++ 3 files changed, 75 insertions(+), 44 deletions(-) create mode 100644 prisma/migrations/20230619073305_ocr_fields_added/migration.sql delete mode 100644 prisma/migrations/20230824071303_add_bed/migration.sql create mode 100644 prisma/migrations/20230825143954_alter_bed_and_asset/migration.sql diff --git a/prisma/migrations/20230619073305_ocr_fields_added/migration.sql b/prisma/migrations/20230619073305_ocr_fields_added/migration.sql new file mode 100644 index 0000000..9fb819c --- /dev/null +++ b/prisma/migrations/20230619073305_ocr_fields_added/migration.sql @@ -0,0 +1,21 @@ +-- AlterTable +ALTER TABLE "Asset" ADD COLUMN "password" TEXT, +ADD COLUMN "port" INTEGER, +ADD COLUMN "username" TEXT; + +-- CreateTable +CREATE TABLE "Bed" ( + "id" SERIAL NOT NULL, + "patientExternalId" TEXT NOT NULL, + "x" INTEGER NOT NULL, + "y" INTEGER NOT NULL, + "zoom" INTEGER NOT NULL DEFAULT 0, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "deleted" BOOLEAN NOT NULL DEFAULT false, + + CONSTRAINT "Bed_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "Bed_patientExternalId_key" ON "Bed"("patientExternalId"); diff --git a/prisma/migrations/20230824071303_add_bed/migration.sql b/prisma/migrations/20230824071303_add_bed/migration.sql deleted file mode 100644 index 1127f2b..0000000 --- a/prisma/migrations/20230824071303_add_bed/migration.sql +++ /dev/null @@ -1,44 +0,0 @@ --- CreateEnum -CREATE TYPE "AssetType" AS ENUM ('CAMERA', 'MONITOR'); - --- AlterTable -ALTER TABLE "Asset" ADD COLUMN "password" TEXT, -ADD COLUMN "port" INTEGER DEFAULT 80, -ADD COLUMN "type" "AssetType" NOT NULL DEFAULT 'MONITOR', -ADD COLUMN "username" TEXT; - --- CreateTable -CREATE TABLE "Bed" ( - "id" SERIAL NOT NULL, - "name" TEXT NOT NULL, - "externalId" TEXT NOT NULL, - "cameraId" INTEGER NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" BOOLEAN NOT NULL DEFAULT false, - - CONSTRAINT "Bed_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Preset" ( - "id" SERIAL NOT NULL, - "x" INTEGER NOT NULL, - "y" INTEGER NOT NULL, - "zoom" INTEGER NOT NULL DEFAULT 0, - "bedId" INTEGER NOT NULL, - - CONSTRAINT "Preset_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "Bed_externalId_key" ON "Bed"("externalId"); - --- CreateIndex -CREATE UNIQUE INDEX "Preset_bedId_key" ON "Preset"("bedId"); - --- AddForeignKey -ALTER TABLE "Bed" ADD CONSTRAINT "Bed_cameraId_fkey" FOREIGN KEY ("cameraId") REFERENCES "Asset"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Preset" ADD CONSTRAINT "Preset_bedId_fkey" FOREIGN KEY ("bedId") REFERENCES "Bed"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20230825143954_alter_bed_and_asset/migration.sql b/prisma/migrations/20230825143954_alter_bed_and_asset/migration.sql new file mode 100644 index 0000000..4aff3a1 --- /dev/null +++ b/prisma/migrations/20230825143954_alter_bed_and_asset/migration.sql @@ -0,0 +1,54 @@ +/* + Warnings: + + - You are about to drop the column `patientExternalId` on the `Bed` table. All the data in the column will be lost. + - You are about to drop the column `x` on the `Bed` table. All the data in the column will be lost. + - You are about to drop the column `y` on the `Bed` table. All the data in the column will be lost. + - You are about to drop the column `zoom` on the `Bed` table. All the data in the column will be lost. + - A unique constraint covering the columns `[externalId]` on the table `Bed` will be added. If there are existing duplicate values, this will fail. + - Added the required column `cameraId` to the `Bed` table without a default value. This is not possible if the table is not empty. + - Added the required column `externalId` to the `Bed` table without a default value. This is not possible if the table is not empty. + - Added the required column `name` to the `Bed` table without a default value. This is not possible if the table is not empty. + +*/ +-- CreateEnum +CREATE TYPE "AssetType" AS ENUM ('CAMERA', 'MONITOR'); + +-- DropIndex +DROP INDEX "Bed_patientExternalId_key"; + +-- AlterTable +ALTER TABLE "Asset" ADD COLUMN "type" "AssetType" NOT NULL DEFAULT 'MONITOR', +ALTER COLUMN "port" SET DEFAULT 80; + +-- AlterTable +ALTER TABLE "Bed" DROP COLUMN "patientExternalId", +DROP COLUMN "x", +DROP COLUMN "y", +DROP COLUMN "zoom", +ADD COLUMN "cameraId" INTEGER NOT NULL, +ADD COLUMN "externalId" TEXT NOT NULL, +ADD COLUMN "name" TEXT NOT NULL; + +-- CreateTable +CREATE TABLE "Preset" ( + "id" SERIAL NOT NULL, + "x" INTEGER NOT NULL, + "y" INTEGER NOT NULL, + "zoom" INTEGER NOT NULL DEFAULT 0, + "bedId" INTEGER NOT NULL, + + CONSTRAINT "Preset_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "Preset_bedId_key" ON "Preset"("bedId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Bed_externalId_key" ON "Bed"("externalId"); + +-- AddForeignKey +ALTER TABLE "Bed" ADD CONSTRAINT "Bed_cameraId_fkey" FOREIGN KEY ("cameraId") REFERENCES "Asset"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Preset" ADD CONSTRAINT "Preset_bedId_fkey" FOREIGN KEY ("bedId") REFERENCES "Bed"("id") ON DELETE RESTRICT ON UPDATE CASCADE;