diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 64a759e..8f2aedf 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -46,7 +46,7 @@ model Project { updatedAt DateTime @updatedAt // Relations - tags Tag[] + tags ProjectTag[] links ExternalLink[] // Indexes @@ -56,14 +56,14 @@ model Project { } model Tag { - id String @id @default(cuid()) - name String @unique + id String @id @default(cuid()) + name String @unique nameEn String? - slug String @unique - createdAt DateTime @default(now()) + slug String @unique + createdAt DateTime @default(now()) // Relations - projects Project[] + projects ProjectTag[] // Indexes @@index([slug], map: "idx_tag_slug") @@ -83,5 +83,21 @@ model ExternalLink { // Indexes @@index([projectId], map: "idx_link_projectId") @@index([type], map: "idx_link_type") + @@index([url], map: "idx_link_url") + @@index([type, url], map: "idx_link_type_url") + @@unique([projectId, url]) @@map("external_links") } + +// Project-Tag many-to-many relationship table +model ProjectTag { + projectId String + tagId String + + project Project @relation(fields: [projectId], references: [id], onDelete: Cascade) + tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade) + + @@id([projectId, tagId]) + @@index([tagId]) + @@map("project_tags") +}