x
This commit is contained in:
1 parent
0ceee3dbff
commit
2d39edbd57
18 files changed
+804
-153
No files matched your search
+25
@@ -0,0 +1,25 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "CategoryMedia" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"categoryId" INTEGER NOT NULL,
|
||||
"role" TEXT NOT NULL,
|
||||
"url" TEXT NOT NULL,
|
||||
"width" INTEGER,
|
||||
"height" INTEGER,
|
||||
"focalX" DOUBLE PRECISION NOT NULL DEFAULT 0.5,
|
||||
"focalY" DOUBLE PRECISION NOT NULL DEFAULT 0.5,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "CategoryMedia_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "CategoryMedia_categoryId_sortOrder_idx" ON "CategoryMedia"("categoryId", "sortOrder");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "CategoryMedia_categoryId_role_key" ON "CategoryMedia"("categoryId", "role");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CategoryMedia" ADD CONSTRAINT "CategoryMedia_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "Category"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
-- Preserve every existing Category.imageUrl as the initial semantic thumbnail.
|
||||
-- The legacy column remains available while API and frontend consumers migrate.
|
||||
INSERT INTO "CategoryMedia" (
|
||||
"categoryId",
|
||||
"role",
|
||||
"url",
|
||||
"focalX",
|
||||
"focalY",
|
||||
"sortOrder",
|
||||
"createdAt",
|
||||
"updatedAt"
|
||||
)
|
||||
SELECT
|
||||
"id",
|
||||
'thumbnail',
|
||||
"imageUrl",
|
||||
0.5,
|
||||
0.5,
|
||||
0,
|
||||
CURRENT_TIMESTAMP,
|
||||
CURRENT_TIMESTAMP
|
||||
FROM "Category"
|
||||
WHERE "imageUrl" IS NOT NULL
|
||||
AND BTRIM("imageUrl") <> ''
|
||||
ON CONFLICT ("categoryId", "role") DO NOTHING;
|
||||
Reference in new issue
Block a user