feat(db): add isResized to GalleryImage

This commit is contained in:
Kirill
2026-05-17 17:39:44 +05:00
parent f36439de38
commit c8281a39e5
3 changed files with 29 additions and 0 deletions
@@ -0,0 +1,15 @@
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_GalleryImage" (
"id" TEXT NOT NULL PRIMARY KEY,
"url" TEXT NOT NULL,
"isResized" BOOLEAN NOT NULL DEFAULT false,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO "new_GalleryImage" ("createdAt", "id", "url") SELECT "createdAt", "id", "url" FROM "GalleryImage";
DROP TABLE "GalleryImage";
ALTER TABLE "new_GalleryImage" RENAME TO "GalleryImage";
CREATE UNIQUE INDEX "GalleryImage_url_key" ON "GalleryImage"("url");
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;
+1
View File
@@ -57,6 +57,7 @@ model ProductImage {
model GalleryImage { model GalleryImage {
id String @id @default(cuid()) id String @id @default(cuid())
url String @unique url String @unique
isResized Boolean @default(false)
createdAt DateTime @default(now()) createdAt DateTime @default(now())
catalogSliderSlides CatalogSliderSlide[] catalogSliderSlides CatalogSliderSlide[]
+13
View File
@@ -0,0 +1,13 @@
import { prisma } from '../src/lib/prisma.js'
async function main() {
const { count } = await prisma.galleryImage.updateMany({
where: { isResized: false },
data: { isResized: true },
})
console.log(`Marked ${count} existing images as resized`)
}
main()
.catch(console.error)
.finally(() => prisma.$disconnect())