Add tags and categories CRUD
This commit is contained in:
		
							
								
								
									
										68
									
								
								prisma/migrations/20250627223557_image_colors/migration.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								prisma/migrations/20250627223557_image_colors/migration.sql
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,68 @@
 | 
			
		||||
/*
 | 
			
		||||
  Warnings:
 | 
			
		||||
 | 
			
		||||
  - You are about to drop the column `imageId` on the `ExtractColor` table. All the data in the column will be lost.
 | 
			
		||||
  - A unique constraint covering the columns `[name]` on the table `ExtractColor` will be added. If there are existing duplicate values, this will fail.
 | 
			
		||||
  - A unique constraint covering the columns `[name]` on the table `ImageColor` will be added. If there are existing duplicate values, this will fail.
 | 
			
		||||
  - Made the column `name` on table `ColorPalette` required. This step will fail if there are existing NULL values in that column.
 | 
			
		||||
  - Made the column `type` on table `ColorPalette` required. This step will fail if there are existing NULL values in that column.
 | 
			
		||||
  - Added the required column `name` to the `ExtractColor` table without a default value. This is not possible if the table is not empty.
 | 
			
		||||
  - Added the required column `name` to the `ImageColor` table without a default value. This is not possible if the table is not empty.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
-- DropForeignKey
 | 
			
		||||
ALTER TABLE "ExtractColor" DROP CONSTRAINT "ExtractColor_imageId_fkey";
 | 
			
		||||
 | 
			
		||||
-- DropForeignKey
 | 
			
		||||
ALTER TABLE "ImageColor" DROP CONSTRAINT "ImageColor_imageId_fkey";
 | 
			
		||||
 | 
			
		||||
-- AlterTable
 | 
			
		||||
ALTER TABLE "ColorPalette" ALTER COLUMN "name" SET NOT NULL,
 | 
			
		||||
ALTER COLUMN "type" SET NOT NULL;
 | 
			
		||||
 | 
			
		||||
-- AlterTable
 | 
			
		||||
ALTER TABLE "ExtractColor" DROP COLUMN "imageId",
 | 
			
		||||
ADD COLUMN     "name" TEXT NOT NULL;
 | 
			
		||||
 | 
			
		||||
-- AlterTable
 | 
			
		||||
ALTER TABLE "ImageColor" ADD COLUMN     "name" TEXT NOT NULL;
 | 
			
		||||
 | 
			
		||||
-- CreateTable
 | 
			
		||||
CREATE TABLE "_ImageToImageColor" (
 | 
			
		||||
    "A" TEXT NOT NULL,
 | 
			
		||||
    "B" TEXT NOT NULL,
 | 
			
		||||
 | 
			
		||||
    CONSTRAINT "_ImageToImageColor_AB_pkey" PRIMARY KEY ("A","B")
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
-- CreateTable
 | 
			
		||||
CREATE TABLE "_ImageToExtractColor" (
 | 
			
		||||
    "A" TEXT NOT NULL,
 | 
			
		||||
    "B" TEXT NOT NULL,
 | 
			
		||||
 | 
			
		||||
    CONSTRAINT "_ImageToExtractColor_AB_pkey" PRIMARY KEY ("A","B")
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
-- CreateIndex
 | 
			
		||||
CREATE INDEX "_ImageToImageColor_B_index" ON "_ImageToImageColor"("B");
 | 
			
		||||
 | 
			
		||||
-- CreateIndex
 | 
			
		||||
CREATE INDEX "_ImageToExtractColor_B_index" ON "_ImageToExtractColor"("B");
 | 
			
		||||
 | 
			
		||||
-- CreateIndex
 | 
			
		||||
CREATE UNIQUE INDEX "ExtractColor_name_key" ON "ExtractColor"("name");
 | 
			
		||||
 | 
			
		||||
-- CreateIndex
 | 
			
		||||
CREATE UNIQUE INDEX "ImageColor_name_key" ON "ImageColor"("name");
 | 
			
		||||
 | 
			
		||||
-- AddForeignKey
 | 
			
		||||
ALTER TABLE "_ImageToImageColor" ADD CONSTRAINT "_ImageToImageColor_A_fkey" FOREIGN KEY ("A") REFERENCES "Image"("id") ON DELETE CASCADE ON UPDATE CASCADE;
 | 
			
		||||
 | 
			
		||||
-- AddForeignKey
 | 
			
		||||
ALTER TABLE "_ImageToImageColor" ADD CONSTRAINT "_ImageToImageColor_B_fkey" FOREIGN KEY ("B") REFERENCES "ImageColor"("id") ON DELETE CASCADE ON UPDATE CASCADE;
 | 
			
		||||
 | 
			
		||||
-- AddForeignKey
 | 
			
		||||
ALTER TABLE "_ImageToExtractColor" ADD CONSTRAINT "_ImageToExtractColor_A_fkey" FOREIGN KEY ("A") REFERENCES "ExtractColor"("id") ON DELETE CASCADE ON UPDATE CASCADE;
 | 
			
		||||
 | 
			
		||||
-- AddForeignKey
 | 
			
		||||
ALTER TABLE "_ImageToExtractColor" ADD CONSTRAINT "_ImageToExtractColor_B_fkey" FOREIGN KEY ("B") REFERENCES "Image"("id") ON DELETE CASCADE ON UPDATE CASCADE;
 | 
			
		||||
@ -0,0 +1,8 @@
 | 
			
		||||
/*
 | 
			
		||||
  Warnings:
 | 
			
		||||
 | 
			
		||||
  - You are about to drop the column `imageId` on the `ImageColor` table. All the data in the column will be lost.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
-- AlterTable
 | 
			
		||||
ALTER TABLE "ImageColor" DROP COLUMN "imageId";
 | 
			
		||||
@ -0,0 +1,61 @@
 | 
			
		||||
-- CreateTable
 | 
			
		||||
CREATE TABLE "Category" (
 | 
			
		||||
    "id" TEXT NOT NULL,
 | 
			
		||||
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
 | 
			
		||||
    "updatedAt" TIMESTAMP(3) NOT NULL,
 | 
			
		||||
    "name" TEXT NOT NULL,
 | 
			
		||||
    "description" TEXT,
 | 
			
		||||
 | 
			
		||||
    CONSTRAINT "Category_pkey" PRIMARY KEY ("id")
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
-- CreateTable
 | 
			
		||||
CREATE TABLE "Tag" (
 | 
			
		||||
    "id" TEXT NOT NULL,
 | 
			
		||||
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
 | 
			
		||||
    "updatedAt" TIMESTAMP(3) NOT NULL,
 | 
			
		||||
    "name" TEXT NOT NULL,
 | 
			
		||||
    "description" TEXT,
 | 
			
		||||
 | 
			
		||||
    CONSTRAINT "Tag_pkey" PRIMARY KEY ("id")
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
-- CreateTable
 | 
			
		||||
CREATE TABLE "_ImageTags" (
 | 
			
		||||
    "A" TEXT NOT NULL,
 | 
			
		||||
    "B" TEXT NOT NULL,
 | 
			
		||||
 | 
			
		||||
    CONSTRAINT "_ImageTags_AB_pkey" PRIMARY KEY ("A","B")
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
-- CreateTable
 | 
			
		||||
CREATE TABLE "_ImageCategories" (
 | 
			
		||||
    "A" TEXT NOT NULL,
 | 
			
		||||
    "B" TEXT NOT NULL,
 | 
			
		||||
 | 
			
		||||
    CONSTRAINT "_ImageCategories_AB_pkey" PRIMARY KEY ("A","B")
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
-- CreateIndex
 | 
			
		||||
CREATE UNIQUE INDEX "Category_name_key" ON "Category"("name");
 | 
			
		||||
 | 
			
		||||
-- CreateIndex
 | 
			
		||||
CREATE UNIQUE INDEX "Tag_name_key" ON "Tag"("name");
 | 
			
		||||
 | 
			
		||||
-- CreateIndex
 | 
			
		||||
CREATE INDEX "_ImageTags_B_index" ON "_ImageTags"("B");
 | 
			
		||||
 | 
			
		||||
-- CreateIndex
 | 
			
		||||
CREATE INDEX "_ImageCategories_B_index" ON "_ImageCategories"("B");
 | 
			
		||||
 | 
			
		||||
-- AddForeignKey
 | 
			
		||||
ALTER TABLE "_ImageTags" ADD CONSTRAINT "_ImageTags_A_fkey" FOREIGN KEY ("A") REFERENCES "Image"("id") ON DELETE CASCADE ON UPDATE CASCADE;
 | 
			
		||||
 | 
			
		||||
-- AddForeignKey
 | 
			
		||||
ALTER TABLE "_ImageTags" ADD CONSTRAINT "_ImageTags_B_fkey" FOREIGN KEY ("B") REFERENCES "Tag"("id") ON DELETE CASCADE ON UPDATE CASCADE;
 | 
			
		||||
 | 
			
		||||
-- AddForeignKey
 | 
			
		||||
ALTER TABLE "_ImageCategories" ADD CONSTRAINT "_ImageCategories_A_fkey" FOREIGN KEY ("A") REFERENCES "Category"("id") ON DELETE CASCADE ON UPDATE CASCADE;
 | 
			
		||||
 | 
			
		||||
-- AddForeignKey
 | 
			
		||||
ALTER TABLE "_ImageCategories" ADD CONSTRAINT "_ImageCategories_B_fkey" FOREIGN KEY ("B") REFERENCES "Image"("id") ON DELETE CASCADE ON UPDATE CASCADE;
 | 
			
		||||
		Reference in New Issue
	
	Block a user