-- CreateTable
CREATE TABLE "ImageMetadata" (
    "id" TEXT NOT NULL,
    "imageId" TEXT NOT NULL,
    "format" TEXT NOT NULL,
    "width" INTEGER NOT NULL,
    "height" INTEGER NOT NULL,
    "space" TEXT NOT NULL,
    "channels" INTEGER NOT NULL,
    "depth" TEXT NOT NULL,
    "density" INTEGER,
    "bitsPerSample" INTEGER,
    "isProgressive" BOOLEAN,
    "isPalette" BOOLEAN,
    "hasProfile" BOOLEAN,
    "hasAlpha" BOOLEAN,
    "autoOrientW" INTEGER,
    "autoOrientH" INTEGER,

    CONSTRAINT "ImageMetadata_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "ImageStats" (
    "id" TEXT NOT NULL,
    "imageId" TEXT NOT NULL,
    "isOpaque" BOOLEAN NOT NULL,
    "entropy" DOUBLE PRECISION NOT NULL,
    "sharpness" DOUBLE PRECISION NOT NULL,
    "dominantR" INTEGER NOT NULL,
    "dominantG" INTEGER NOT NULL,
    "dominantB" INTEGER NOT NULL,

    CONSTRAINT "ImageStats_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "ImageMetadata_imageId_key" ON "ImageMetadata"("imageId");

-- CreateIndex
CREATE UNIQUE INDEX "ImageStats_imageId_key" ON "ImageStats"("imageId");

-- AddForeignKey
ALTER TABLE "ImageMetadata" ADD CONSTRAINT "ImageMetadata_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "Image"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ImageStats" ADD CONSTRAINT "ImageStats_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "Image"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
