From c16ff6631201caac7081ae060766f4457f7fbe8c Mon Sep 17 00:00:00 2001 From: Karthik Kalyanaraman <105607645+karthikscale3@users.noreply.github.com> Date: Tue, 2 Jul 2024 21:56:23 -0700 Subject: [PATCH] Fix database migration drift (#166) * Pagination bug * Bug fix * Bugfixes * Fix migration drift --- .../migration.sql | 16 +-------- .../migration.sql | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 prisma/migrations/20240703045034_add_api_key_hash/migration.sql diff --git a/prisma/migrations/20240626153855_add_api_key_hash_to_team/migration.sql b/prisma/migrations/20240626153855_add_api_key_hash_to_team/migration.sql index ce9848e3..d285b954 100644 --- a/prisma/migrations/20240626153855_add_api_key_hash_to_team/migration.sql +++ b/prisma/migrations/20240626153855_add_api_key_hash_to_team/migration.sql @@ -1,19 +1,5 @@ -/* - Warnings: - - - You are about to drop the column `expectedOutput` on the `Data` table. All the data in the column will be lost. - - You are about to drop the column `runId` on the `Data` table. All the data in the column will be lost. - - You are about to drop the column `name` on the `Run` table. All the data in the column will be lost. - - A unique constraint covering the columns `[apiKeyHash]` on the table `Team` will be added. If there are existing duplicate values, this will fail. - - Added the required column `projectId` to the `Run` table without a default value. This is not possible if the table is not empty. - - Added the required column `runId` to the `Run` table without a default value. This is not possible if the table is not empty. - - Added the required column `taskId` to the `Run` table without a default value. This is not possible if the table is not empty. - - Added the required column `updatedAt` to the `Run` table without a default value. This is not possible if the table is not empty. - -*/ - -- AlterTable -ALTER TABLE "Team" ADD COLUMN "apiKeyHash" TEXT; +ALTER TABLE "Team" ADD COLUMN "apiKeyHash" TEXT; -- CreateIndex CREATE UNIQUE INDEX "Team_apiKeyHash_key" ON "Team"("apiKeyHash"); diff --git a/prisma/migrations/20240703045034_add_api_key_hash/migration.sql b/prisma/migrations/20240703045034_add_api_key_hash/migration.sql new file mode 100644 index 00000000..c648c4bc --- /dev/null +++ b/prisma/migrations/20240703045034_add_api_key_hash/migration.sql @@ -0,0 +1,36 @@ +/* + Warnings: + + - You are about to drop the column `expectedOutput` on the `Data` table. All the data in the column will be lost. + - You are about to drop the column `runId` on the `Data` table. All the data in the column will be lost. + - You are about to drop the column `name` on the `Run` table. All the data in the column will be lost. + - Added the required column `projectId` to the `Run` table without a default value. This is not possible if the table is not empty. + - Added the required column `runId` to the `Run` table without a default value. This is not possible if the table is not empty. + - Added the required column `taskId` to the `Run` table without a default value. This is not possible if the table is not empty. + - Added the required column `updatedAt` to the `Run` table without a default value. This is not possible if the table is not empty. + +*/ +-- DropForeignKey +ALTER TABLE "Data" DROP CONSTRAINT "Data_runId_fkey"; + +-- AlterTable +ALTER TABLE "Data" DROP COLUMN "expectedOutput", +DROP COLUMN "runId", +ADD COLUMN "annotatedOutput" TEXT; + +-- AlterTable +ALTER TABLE "Run" DROP COLUMN "name", +ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, +ADD COLUMN "datasetId" TEXT, +ADD COLUMN "log" JSONB, +ADD COLUMN "projectId" TEXT NOT NULL, +ADD COLUMN "runId" TEXT NOT NULL, +ADD COLUMN "taskId" TEXT NOT NULL, +ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL, +ADD COLUMN "wfVersion" TEXT; + +-- AddForeignKey +ALTER TABLE "Run" ADD CONSTRAINT "Run_datasetId_fkey" FOREIGN KEY ("datasetId") REFERENCES "Dataset"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Run" ADD CONSTRAINT "Run_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE CASCADE ON UPDATE CASCADE;