Refactor colors and palettes
This commit is contained in:
@ -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;
|
@ -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";
|
@ -24,8 +24,8 @@ model Gallery {
|
||||
|
||||
description String?
|
||||
|
||||
// coverImageId String?
|
||||
// coverImage Image? @relation("GalleryCoverImage", fields: [coverImageId], references: [id])
|
||||
coverImageId String?
|
||||
coverImage Image? @relation("GalleryCoverImage", fields: [coverImageId], references: [id])
|
||||
|
||||
albums Album[]
|
||||
}
|
||||
@ -35,17 +35,19 @@ model Album {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
name String
|
||||
slug String
|
||||
name String
|
||||
|
||||
description String?
|
||||
|
||||
// coverImageId String?
|
||||
galleryId String?
|
||||
// coverImage Image? @relation("AlbumCoverImage", fields: [coverImageId], references: [id])
|
||||
gallery Gallery? @relation(fields: [galleryId], references: [id])
|
||||
coverImageId String?
|
||||
galleryId String?
|
||||
coverImage Image? @relation("AlbumCoverImage", fields: [coverImageId], references: [id])
|
||||
gallery Gallery? @relation(fields: [galleryId], references: [id])
|
||||
|
||||
images Image[]
|
||||
|
||||
@@unique([galleryId, slug])
|
||||
}
|
||||
|
||||
model Artist {
|
||||
@ -77,6 +79,30 @@ model Social {
|
||||
artist Artist? @relation(fields: [artistId], references: [id])
|
||||
}
|
||||
|
||||
model Category {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
name String @unique
|
||||
|
||||
description String?
|
||||
|
||||
images Image[] @relation("ImageCategories")
|
||||
}
|
||||
|
||||
model Tag {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
name String @unique
|
||||
|
||||
description String?
|
||||
|
||||
images Image[] @relation("ImageTags")
|
||||
}
|
||||
|
||||
model Image {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
@ -91,6 +117,7 @@ model Image {
|
||||
description String?
|
||||
fileType String?
|
||||
imageData String?
|
||||
source String?
|
||||
creationMonth Int?
|
||||
creationYear Int?
|
||||
fileSize Int?
|
||||
@ -100,22 +127,22 @@ model Image {
|
||||
artistId String?
|
||||
album Album? @relation(fields: [albumId], references: [id])
|
||||
artist Artist? @relation(fields: [artistId], references: [id])
|
||||
// sourceId String?
|
||||
// source Source? @relation(fields: [sourceId], references: [id])
|
||||
|
||||
metadata ImageMetadata[]
|
||||
pixels PixelSummary[]
|
||||
stats ImageStats[]
|
||||
theme ThemeSeed[]
|
||||
variants ImageVariant[]
|
||||
metadata ImageMetadata?
|
||||
stats ImageStats?
|
||||
|
||||
// albumCover Album[] @relation("AlbumCoverImage")
|
||||
// galleryCover Gallery[] @relation("GalleryCoverImage")
|
||||
categories Category[] @relation("ImageCategories")
|
||||
colors ImageColor[] @relation("ImageToImageColor")
|
||||
extractColors ExtractColor[] @relation("ImageToExtractColor")
|
||||
palettes ColorPalette[] @relation("ImagePalettes")
|
||||
tags Tag[] @relation("ImageTags")
|
||||
colors ImageColor[]
|
||||
extractColors ImageExtractColor[]
|
||||
palettes ImagePalette[]
|
||||
variants ImageVariant[]
|
||||
// pixels PixelSummary[]
|
||||
// theme ThemeSeed[]
|
||||
albumCover Album[] @relation("AlbumCoverImage")
|
||||
galleryCover Gallery[] @relation("GalleryCoverImage")
|
||||
categories Category[] @relation("ImageCategories")
|
||||
// colors ImageColor[] @relation("ImageToImageColor")
|
||||
tags Tag[] @relation("ImageTags")
|
||||
// palettes ColorPalette[] @relation("ImagePalettes")
|
||||
}
|
||||
|
||||
model ImageMetadata {
|
||||
@ -123,7 +150,7 @@ model ImageMetadata {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
imageId String
|
||||
imageId String @unique
|
||||
depth String
|
||||
format String
|
||||
space String
|
||||
@ -148,7 +175,7 @@ model ImageStats {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
imageId String
|
||||
imageId String @unique
|
||||
entropy Float
|
||||
sharpness Float
|
||||
dominantB Int
|
||||
@ -184,10 +211,10 @@ model ColorPalette {
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
name String
|
||||
type String
|
||||
|
||||
items ColorPaletteItem[]
|
||||
images Image[] @relation("ImagePalettes")
|
||||
images ImagePalette[]
|
||||
// images Image[] @relation("ImagePalettes")
|
||||
}
|
||||
|
||||
model ColorPaletteItem {
|
||||
@ -217,10 +244,11 @@ model ExtractColor {
|
||||
hue Float?
|
||||
saturation Float?
|
||||
|
||||
images Image[] @relation("ImageToExtractColor")
|
||||
// images Image[] @relation("ImageToExtractColor")
|
||||
images ImageExtractColor[]
|
||||
}
|
||||
|
||||
model ImageColor {
|
||||
model Color {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@ -233,53 +261,74 @@ model ImageColor {
|
||||
green Int?
|
||||
red Int?
|
||||
|
||||
images Image[] @relation("ImageToImageColor")
|
||||
images ImageColor[]
|
||||
}
|
||||
|
||||
model ThemeSeed {
|
||||
// model ThemeSeed {
|
||||
// id String @id @default(cuid())
|
||||
// createdAt DateTime @default(now())
|
||||
// updatedAt DateTime @updatedAt
|
||||
|
||||
// imageId String
|
||||
// seedHex String
|
||||
|
||||
// image Image @relation(fields: [imageId], references: [id])
|
||||
// }
|
||||
|
||||
// model PixelSummary {
|
||||
// id String @id @default(cuid())
|
||||
// createdAt DateTime @default(now())
|
||||
// updatedAt DateTime @updatedAt
|
||||
|
||||
// imageId String
|
||||
// channels Int
|
||||
// height Int
|
||||
// width Int
|
||||
|
||||
// image Image @relation(fields: [imageId], references: [id])
|
||||
// }
|
||||
|
||||
model ImagePalette {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
imageId String
|
||||
paletteId String
|
||||
type String
|
||||
|
||||
image Image @relation(fields: [imageId], references: [id])
|
||||
palette ColorPalette @relation(fields: [paletteId], references: [id])
|
||||
|
||||
@@unique([imageId, type])
|
||||
}
|
||||
|
||||
model ImageExtractColor {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
imageId String
|
||||
extractId String
|
||||
type String
|
||||
|
||||
image Image @relation(fields: [imageId], references: [id])
|
||||
extract ExtractColor @relation(fields: [extractId], references: [id])
|
||||
|
||||
@@unique([imageId, type])
|
||||
}
|
||||
|
||||
model ImageColor {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
imageId String
|
||||
seedHex String
|
||||
colorId String
|
||||
type String
|
||||
|
||||
image Image @relation(fields: [imageId], references: [id])
|
||||
}
|
||||
|
||||
model PixelSummary {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
imageId String
|
||||
channels Int
|
||||
height Int
|
||||
width Int
|
||||
|
||||
image Image @relation(fields: [imageId], references: [id])
|
||||
}
|
||||
|
||||
model Category {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
name String @unique
|
||||
|
||||
description String?
|
||||
|
||||
images Image[] @relation("ImageCategories")
|
||||
}
|
||||
|
||||
model Tag {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
name String @unique
|
||||
|
||||
description String?
|
||||
|
||||
images Image[] @relation("ImageTags")
|
||||
color Color @relation(fields: [colorId], references: [id])
|
||||
|
||||
@@unique([imageId, type])
|
||||
}
|
||||
|
Reference in New Issue
Block a user