Add image upload function
This commit is contained in:
26
prisma/migrations/20250625150825_image/migration.sql
Normal file
26
prisma/migrations/20250625150825_image/migration.sql
Normal file
@ -0,0 +1,26 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "Image" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"fileKey" TEXT NOT NULL,
|
||||
"imageName" TEXT NOT NULL,
|
||||
"originalFile" TEXT NOT NULL,
|
||||
"uploadDate" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"altText" TEXT,
|
||||
"description" TEXT,
|
||||
"imageData" TEXT,
|
||||
"creationMonth" INTEGER,
|
||||
"creationYear" INTEGER,
|
||||
"creationDate" TIMESTAMP(3),
|
||||
"albumId" TEXT,
|
||||
"artistId" TEXT,
|
||||
|
||||
CONSTRAINT "Image_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Image" ADD CONSTRAINT "Image_albumId_fkey" FOREIGN KEY ("albumId") REFERENCES "Album"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Image" ADD CONSTRAINT "Image_artistId_fkey" FOREIGN KEY ("artistId") REFERENCES "Artist"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
@ -0,0 +1,47 @@
|
||||
-- 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;
|
38
prisma/migrations/20250626184532_image_variant/migration.sql
Normal file
38
prisma/migrations/20250626184532_image_variant/migration.sql
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `updatedAt` to the `ImageMetadata` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `updatedAt` to the `ImageStats` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "ImageMetadata" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "ImageStats" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ImageVariant" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"imageId" TEXT NOT NULL,
|
||||
"s3Key" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"height" INTEGER NOT NULL,
|
||||
"width" INTEGER NOT NULL,
|
||||
"fileExtension" TEXT,
|
||||
"mimeType" TEXT,
|
||||
"url" TEXT,
|
||||
"sizeBytes" INTEGER,
|
||||
|
||||
CONSTRAINT "ImageVariant_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ImageVariant_imageId_key" ON "ImageVariant"("imageId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ImageVariant" ADD CONSTRAINT "ImageVariant_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "Image"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
3
prisma/migrations/20250626184958_image/migration.sql
Normal file
3
prisma/migrations/20250626184958_image/migration.sql
Normal file
@ -0,0 +1,3 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Image" ADD COLUMN "fileSize" INTEGER,
|
||||
ADD COLUMN "fileType" TEXT;
|
42
prisma/migrations/20250626190045_color_palette/migration.sql
Normal file
42
prisma/migrations/20250626190045_color_palette/migration.sql
Normal file
@ -0,0 +1,42 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "ColorPalette" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"name" TEXT,
|
||||
"type" TEXT,
|
||||
|
||||
CONSTRAINT "ColorPalette_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ColorPaletteItem" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"tone" INTEGER,
|
||||
"hex" TEXT,
|
||||
"colorPaletteId" TEXT,
|
||||
|
||||
CONSTRAINT "ColorPaletteItem_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "_ImagePalettes" (
|
||||
"A" TEXT NOT NULL,
|
||||
"B" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "_ImagePalettes_AB_pkey" PRIMARY KEY ("A","B")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "_ImagePalettes_B_index" ON "_ImagePalettes"("B");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ColorPaletteItem" ADD CONSTRAINT "ColorPaletteItem_colorPaletteId_fkey" FOREIGN KEY ("colorPaletteId") REFERENCES "ColorPalette"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_ImagePalettes" ADD CONSTRAINT "_ImagePalettes_A_fkey" FOREIGN KEY ("A") REFERENCES "ColorPalette"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_ImagePalettes" ADD CONSTRAINT "_ImagePalettes_B_fkey" FOREIGN KEY ("B") REFERENCES "Image"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
78
prisma/migrations/20250626191041_colors/migration.sql
Normal file
78
prisma/migrations/20250626191041_colors/migration.sql
Normal file
@ -0,0 +1,78 @@
|
||||
-- DropIndex
|
||||
DROP INDEX "ImageMetadata_imageId_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "ImageStats_imageId_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "ImageVariant_imageId_key";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ExtractColor" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"hex" TEXT NOT NULL,
|
||||
"imageId" TEXT NOT NULL,
|
||||
"blue" INTEGER NOT NULL,
|
||||
"green" INTEGER NOT NULL,
|
||||
"red" INTEGER NOT NULL,
|
||||
"isLight" BOOLEAN NOT NULL,
|
||||
"area" DOUBLE PRECISION,
|
||||
"hue" DOUBLE PRECISION,
|
||||
"saturation" DOUBLE PRECISION,
|
||||
"value" DOUBLE PRECISION,
|
||||
|
||||
CONSTRAINT "ExtractColor_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ImageColor" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"imageId" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"hex" TEXT,
|
||||
"blue" INTEGER,
|
||||
"green" INTEGER,
|
||||
"red" INTEGER,
|
||||
|
||||
CONSTRAINT "ImageColor_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ThemeSeed" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"imageId" TEXT NOT NULL,
|
||||
"seedHex" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "ThemeSeed_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PixelSummary" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"imageId" TEXT NOT NULL,
|
||||
"channels" INTEGER NOT NULL,
|
||||
"height" INTEGER NOT NULL,
|
||||
"width" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "PixelSummary_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ExtractColor" ADD CONSTRAINT "ExtractColor_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "Image"("id") ON DELETE RESTRICT 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 "ThemeSeed" ADD CONSTRAINT "ThemeSeed_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "Image"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PixelSummary" ADD CONSTRAINT "PixelSummary_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "Image"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
@ -0,0 +1,10 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `isLight` on the `ExtractColor` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `value` on the `ExtractColor` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "ExtractColor" DROP COLUMN "isLight",
|
||||
DROP COLUMN "value";
|
@ -19,8 +19,8 @@ model Gallery {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
name String
|
||||
slug String @unique
|
||||
name String
|
||||
|
||||
description String?
|
||||
|
||||
@ -45,7 +45,7 @@ model Album {
|
||||
// coverImage Image? @relation("AlbumCoverImage", fields: [coverImageId], references: [id])
|
||||
gallery Gallery? @relation(fields: [galleryId], references: [id])
|
||||
|
||||
// images Image[]
|
||||
images Image[]
|
||||
}
|
||||
|
||||
model Artist {
|
||||
@ -53,16 +53,13 @@ model Artist {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
displayName String
|
||||
slug String @unique
|
||||
displayName String
|
||||
|
||||
nickname String?
|
||||
// mentionUrl String?
|
||||
// contact String?
|
||||
// urls String[]
|
||||
|
||||
socials Social[]
|
||||
// images Image[]
|
||||
images Image[]
|
||||
}
|
||||
|
||||
model Social {
|
||||
@ -70,8 +67,8 @@ model Social {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
platform String
|
||||
handle String
|
||||
platform String
|
||||
isPrimary Boolean
|
||||
|
||||
link String?
|
||||
@ -79,3 +76,190 @@ model Social {
|
||||
artistId String?
|
||||
artist Artist? @relation(fields: [artistId], references: [id])
|
||||
}
|
||||
|
||||
model Image {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
fileKey String
|
||||
imageName String
|
||||
originalFile String
|
||||
uploadDate DateTime @default(now())
|
||||
|
||||
altText String?
|
||||
description String?
|
||||
fileType String?
|
||||
imageData String?
|
||||
creationMonth Int?
|
||||
creationYear Int?
|
||||
fileSize Int?
|
||||
creationDate DateTime?
|
||||
|
||||
albumId String?
|
||||
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])
|
||||
|
||||
colors ImageColor[]
|
||||
extractColors ExtractColor[]
|
||||
metadata ImageMetadata[]
|
||||
pixels PixelSummary[]
|
||||
stats ImageStats[]
|
||||
theme ThemeSeed[]
|
||||
variants ImageVariant[]
|
||||
// colors ImageColor[]
|
||||
// extractColors ExtractColor[]
|
||||
//
|
||||
// albumCover Album[] @relation("AlbumCoverImage")
|
||||
// categories Category[] @relation("ImageCategories")
|
||||
// galleryCover Gallery[] @relation("GalleryCoverImage")
|
||||
palettes ColorPalette[] @relation("ImagePalettes")
|
||||
// tags Tag[] @relation("ImageTags")
|
||||
}
|
||||
|
||||
model ImageMetadata {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
imageId String
|
||||
depth String
|
||||
format String
|
||||
space String
|
||||
channels Int
|
||||
height Int
|
||||
width Int
|
||||
|
||||
autoOrientH Int?
|
||||
autoOrientW Int?
|
||||
bitsPerSample Int?
|
||||
density Int?
|
||||
hasAlpha Boolean?
|
||||
hasProfile Boolean?
|
||||
isPalette Boolean?
|
||||
isProgressive Boolean?
|
||||
|
||||
image Image @relation(fields: [imageId], references: [id])
|
||||
}
|
||||
|
||||
model ImageStats {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
imageId String
|
||||
entropy Float
|
||||
sharpness Float
|
||||
dominantB Int
|
||||
dominantG Int
|
||||
dominantR Int
|
||||
isOpaque Boolean
|
||||
|
||||
image Image @relation(fields: [imageId], references: [id])
|
||||
}
|
||||
|
||||
model ImageVariant {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
imageId String
|
||||
s3Key String
|
||||
type String
|
||||
height Int
|
||||
width Int
|
||||
|
||||
fileExtension String?
|
||||
mimeType String?
|
||||
url String?
|
||||
sizeBytes Int?
|
||||
|
||||
image Image @relation(fields: [imageId], references: [id])
|
||||
}
|
||||
|
||||
model ColorPalette {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
name String?
|
||||
type String?
|
||||
|
||||
items ColorPaletteItem[]
|
||||
images Image[] @relation("ImagePalettes")
|
||||
}
|
||||
|
||||
model ColorPaletteItem {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
tone Int?
|
||||
hex String?
|
||||
|
||||
colorPaletteId String?
|
||||
colorPalette ColorPalette? @relation(fields: [colorPaletteId], references: [id])
|
||||
}
|
||||
|
||||
model ExtractColor {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
hex String
|
||||
imageId String
|
||||
blue Int
|
||||
green Int
|
||||
red Int
|
||||
// isLight Boolean
|
||||
|
||||
area Float?
|
||||
hue Float?
|
||||
saturation Float?
|
||||
// value Float?
|
||||
|
||||
image Image @relation(fields: [imageId], references: [id])
|
||||
}
|
||||
|
||||
model ImageColor {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
imageId String
|
||||
type String
|
||||
|
||||
hex String?
|
||||
blue Int?
|
||||
green Int?
|
||||
red Int?
|
||||
|
||||
image Image @relation(fields: [imageId], references: [id])
|
||||
}
|
||||
|
||||
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])
|
||||
}
|
||||
|
Reference in New Issue
Block a user