Refactor colors and palettes

This commit is contained in:
2025-06-28 16:41:01 +02:00
parent 2a2cde2f02
commit 50617e5578
34 changed files with 872 additions and 243 deletions

View File

@ -0,0 +1,172 @@
/*
Warnings:
- You are about to drop the column `type` on the `ColorPalette` table. All the data in the column will be lost.
- You are about to drop the column `blue` on the `ImageColor` table. All the data in the column will be lost.
- You are about to drop the column `green` on the `ImageColor` table. All the data in the column will be lost.
- You are about to drop the column `hex` on the `ImageColor` table. All the data in the column will be lost.
- You are about to drop the column `name` on the `ImageColor` table. All the data in the column will be lost.
- You are about to drop the column `red` on the `ImageColor` table. All the data in the column will be lost.
- You are about to drop the `PixelSummary` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `ThemeSeed` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `_ImagePalettes` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `_ImageToExtractColor` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `_ImageToImageColor` table. If the table is not empty, all the data it contains will be lost.
- A unique constraint covering the columns `[galleryId,slug]` on the table `Album` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[imageId,type]` on the table `ImageColor` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[imageId]` on the table `ImageMetadata` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[imageId]` on the table `ImageStats` will be added. If there are existing duplicate values, this will fail.
- Added the required column `colorId` to the `ImageColor` table without a default value. This is not possible if the table is not empty.
- Added the required column `imageId` to the `ImageColor` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "PixelSummary" DROP CONSTRAINT "PixelSummary_imageId_fkey";
-- DropForeignKey
ALTER TABLE "ThemeSeed" DROP CONSTRAINT "ThemeSeed_imageId_fkey";
-- DropForeignKey
ALTER TABLE "_ImagePalettes" DROP CONSTRAINT "_ImagePalettes_A_fkey";
-- DropForeignKey
ALTER TABLE "_ImagePalettes" DROP CONSTRAINT "_ImagePalettes_B_fkey";
-- DropForeignKey
ALTER TABLE "_ImageToExtractColor" DROP CONSTRAINT "_ImageToExtractColor_A_fkey";
-- DropForeignKey
ALTER TABLE "_ImageToExtractColor" DROP CONSTRAINT "_ImageToExtractColor_B_fkey";
-- DropForeignKey
ALTER TABLE "_ImageToImageColor" DROP CONSTRAINT "_ImageToImageColor_A_fkey";
-- DropForeignKey
ALTER TABLE "_ImageToImageColor" DROP CONSTRAINT "_ImageToImageColor_B_fkey";
-- DropIndex
DROP INDEX "ImageColor_name_key";
-- AlterTable
ALTER TABLE "Album" ADD COLUMN "coverImageId" TEXT;
-- AlterTable
ALTER TABLE "ColorPalette" DROP COLUMN "type";
-- AlterTable
ALTER TABLE "Gallery" ADD COLUMN "coverImageId" TEXT;
-- AlterTable
ALTER TABLE "Image" ADD COLUMN "source" TEXT;
-- AlterTable
ALTER TABLE "ImageColor" DROP COLUMN "blue",
DROP COLUMN "green",
DROP COLUMN "hex",
DROP COLUMN "name",
DROP COLUMN "red",
ADD COLUMN "colorId" TEXT NOT NULL,
ADD COLUMN "imageId" TEXT NOT NULL;
-- DropTable
DROP TABLE "PixelSummary";
-- DropTable
DROP TABLE "ThemeSeed";
-- DropTable
DROP TABLE "_ImagePalettes";
-- DropTable
DROP TABLE "_ImageToExtractColor";
-- DropTable
DROP TABLE "_ImageToImageColor";
-- CreateTable
CREATE TABLE "Color" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"name" TEXT NOT NULL,
"type" TEXT NOT NULL,
"hex" TEXT,
"blue" INTEGER,
"green" INTEGER,
"red" INTEGER,
CONSTRAINT "Color_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "ImagePalette" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"imageId" TEXT NOT NULL,
"paletteId" TEXT NOT NULL,
"type" TEXT NOT NULL,
CONSTRAINT "ImagePalette_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "ImageExtractColor" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"imageId" TEXT NOT NULL,
"extractId" TEXT NOT NULL,
"type" TEXT NOT NULL,
"colorId" TEXT,
CONSTRAINT "ImageExtractColor_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Color_name_key" ON "Color"("name");
-- CreateIndex
CREATE UNIQUE INDEX "ImagePalette_imageId_type_key" ON "ImagePalette"("imageId", "type");
-- CreateIndex
CREATE UNIQUE INDEX "ImageExtractColor_imageId_type_key" ON "ImageExtractColor"("imageId", "type");
-- CreateIndex
CREATE UNIQUE INDEX "Album_galleryId_slug_key" ON "Album"("galleryId", "slug");
-- CreateIndex
CREATE UNIQUE INDEX "ImageColor_imageId_type_key" ON "ImageColor"("imageId", "type");
-- CreateIndex
CREATE UNIQUE INDEX "ImageMetadata_imageId_key" ON "ImageMetadata"("imageId");
-- CreateIndex
CREATE UNIQUE INDEX "ImageStats_imageId_key" ON "ImageStats"("imageId");
-- AddForeignKey
ALTER TABLE "Gallery" ADD CONSTRAINT "Gallery_coverImageId_fkey" FOREIGN KEY ("coverImageId") REFERENCES "Image"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Album" ADD CONSTRAINT "Album_coverImageId_fkey" FOREIGN KEY ("coverImageId") REFERENCES "Image"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "ImagePalette" ADD CONSTRAINT "ImagePalette_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "Image"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "ImagePalette" ADD CONSTRAINT "ImagePalette_paletteId_fkey" FOREIGN KEY ("paletteId") REFERENCES "ColorPalette"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "ImageExtractColor" ADD CONSTRAINT "ImageExtractColor_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "Image"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "ImageExtractColor" ADD CONSTRAINT "ImageExtractColor_extractId_fkey" FOREIGN KEY ("extractId") REFERENCES "ExtractColor"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "ImageExtractColor" ADD CONSTRAINT "ImageExtractColor_colorId_fkey" FOREIGN KEY ("colorId") REFERENCES "Color"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "ImageColor" ADD CONSTRAINT "ImageColor_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "Image"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "ImageColor" ADD CONSTRAINT "ImageColor_colorId_fkey" FOREIGN KEY ("colorId") REFERENCES "Color"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,11 @@
/*
Warnings:
- You are about to drop the column `colorId` on the `ImageExtractColor` table. All the data in the column will be lost.
*/
-- DropForeignKey
ALTER TABLE "ImageExtractColor" DROP CONSTRAINT "ImageExtractColor_colorId_fkey";
-- AlterTable
ALTER TABLE "ImageExtractColor" DROP COLUMN "colorId";