🗃️ db: update schema for new collection

This commit is contained in:
2026-03-27 22:56:18 +07:00
parent dade012888
commit e798338107
2 changed files with 18 additions and 1 deletions

View File

@ -0,0 +1,14 @@
/*
Warnings:
- You are about to alter the column `name` on the `collections` table. The data in that column could be lost. The data in that column will be cast from `VarChar(255)` to `VarChar(115)`.
- A unique constraint covering the columns `[slug,ownerId]` on the table `collections` will be added. If there are existing duplicate values, this will fail.
- Added the required column `slug` to the `collections` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "collections" ADD COLUMN "slug" VARCHAR(115) NOT NULL,
ALTER COLUMN "name" SET DATA TYPE VARCHAR(115);
-- CreateIndex
CREATE UNIQUE INDEX "collections_slug_ownerId_key" ON "collections"("slug", "ownerId");

View File

@ -418,7 +418,8 @@ model UserLog {
model Collection { model Collection {
id String @id @db.Uuid id String @id @db.Uuid
name String @db.VarChar(255) name String @db.VarChar(115)
slug String @db.VarChar(115)
medias Media[] @relation("MediaCollections") medias Media[] @relation("MediaCollections")
owner User @relation("UserCollections", fields: [ownerId], references: [id]) owner User @relation("UserCollections", fields: [ownerId], references: [id])
ownerId String @db.Uuid ownerId String @db.Uuid
@ -429,6 +430,8 @@ model Collection {
deletedAt DateTime? deletedAt DateTime?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt updatedAt DateTime @default(now()) @updatedAt
@@unique([slug, ownerId])
@@map("collections") @@map("collections")
} }