From 221d0c4b264c14a3db6faaabd36ebc9c592495d6 Mon Sep 17 00:00:00 2001 From: charles-gauthereau Date: Mon, 11 Nov 2024 16:25:16 +0100 Subject: [PATCH] Migrations --- .../20241111091911_2024_11_11/migration.sql | 46 ------------------- .../20241111112810_2024_11_11/migration.sql | 2 - .../20241111152326_2024_11_11/migration.sql | 15 ++++++ 3 files changed, 15 insertions(+), 48 deletions(-) delete mode 100755 prisma/migrations/20241111091911_2024_11_11/migration.sql delete mode 100755 prisma/migrations/20241111112810_2024_11_11/migration.sql create mode 100644 prisma/migrations/20241111152326_2024_11_11/migration.sql diff --git a/prisma/migrations/20241111091911_2024_11_11/migration.sql b/prisma/migrations/20241111091911_2024_11_11/migration.sql deleted file mode 100755 index 37a8421c..00000000 --- a/prisma/migrations/20241111091911_2024_11_11/migration.sql +++ /dev/null @@ -1,46 +0,0 @@ --- CreateEnum -CREATE TYPE "Status" AS ENUM ('waiting', 'ongoing', 'failed', 'success'); - --- CreateTable -CREATE TABLE "Agent" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "description" TEXT, - "last_contact" TIMESTAMP(3), - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Agent_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Database" ( - "id" TEXT NOT NULL, - "agent_id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "description" TEXT, - "backup_policy" TEXT, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Database_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Backup" ( - "id" TEXT NOT NULL, - "database_id" TEXT NOT NULL, - "status" "Status" NOT NULL DEFAULT 'waiting', - "file" TEXT, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Backup_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Restore" ( - "id" TEXT NOT NULL, - "backup_id" TEXT NOT NULL, - "status" "Status" NOT NULL DEFAULT 'waiting', - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Restore_pkey" PRIMARY KEY ("id") -); diff --git a/prisma/migrations/20241111112810_2024_11_11/migration.sql b/prisma/migrations/20241111112810_2024_11_11/migration.sql deleted file mode 100755 index b4621b56..00000000 --- a/prisma/migrations/20241111112810_2024_11_11/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AddForeignKey -ALTER TABLE "Database" ADD CONSTRAINT "Database_agent_id_fkey" FOREIGN KEY ("agent_id") REFERENCES "Agent"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20241111152326_2024_11_11/migration.sql b/prisma/migrations/20241111152326_2024_11_11/migration.sql new file mode 100644 index 00000000..8a710941 --- /dev/null +++ b/prisma/migrations/20241111152326_2024_11_11/migration.sql @@ -0,0 +1,15 @@ +/* + Warnings: + + - A unique constraint covering the columns `[slug]` on the table `Agent` will be added. If there are existing duplicate values, this will fail. + - Added the required column `slug` to the `Agent` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "Agent" ADD COLUMN "slug" TEXT NOT NULL; + +-- CreateIndex +CREATE UNIQUE INDEX "Agent_slug_key" ON "Agent"("slug"); + +-- AddForeignKey +ALTER TABLE "Database" ADD CONSTRAINT "Database_agent_id_fkey" FOREIGN KEY ("agent_id") REFERENCES "Agent"("id") ON DELETE CASCADE ON UPDATE CASCADE;