mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-10 13:07:28 +02:00
✨ Add space member model (#1780)
This commit is contained in:
parent
dd9bdbcfc4
commit
424f39ae6b
8 changed files with 200 additions and 68 deletions
39
packages/database/prisma/models/space.prisma
Normal file
39
packages/database/prisma/models/space.prisma
Normal file
|
@ -0,0 +1,39 @@
|
|||
model Space {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
ownerId String @map("owner_id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
owner User @relation("UserSpaces", fields: [ownerId], references: [id], onDelete: Cascade)
|
||||
polls Poll[]
|
||||
scheduledEvents ScheduledEvent[]
|
||||
subscription Subscription? @relation("SpaceToSubscription")
|
||||
|
||||
members SpaceMember[]
|
||||
|
||||
@@index([ownerId], type: Hash)
|
||||
@@map("spaces")
|
||||
}
|
||||
|
||||
enum SpaceMemberRole {
|
||||
OWNER
|
||||
ADMIN
|
||||
MEMBER
|
||||
}
|
||||
|
||||
model SpaceMember {
|
||||
id String @id @default(uuid())
|
||||
spaceId String @map("space_id")
|
||||
userId String @map("user_id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
role SpaceMemberRole @default(MEMBER)
|
||||
|
||||
space Space @relation(fields: [spaceId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([spaceId, userId])
|
||||
@@index([spaceId])
|
||||
@@map("space_members")
|
||||
}
|
|
@ -33,22 +33,22 @@ enum UserRole {
|
|||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
email String @unique() @db.Citext
|
||||
emailVerified DateTime? @map("email_verified")
|
||||
image String?
|
||||
timeZone String? @map("time_zone")
|
||||
weekStart Int? @map("week_start")
|
||||
timeFormat TimeFormat? @map("time_format")
|
||||
locale String?
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime? @updatedAt @map("updated_at")
|
||||
customerId String? @map("customer_id")
|
||||
banned Boolean @default(false)
|
||||
bannedAt DateTime? @map("banned_at")
|
||||
banReason String? @map("ban_reason")
|
||||
role UserRole @default(user)
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
email String @unique() @db.Citext
|
||||
emailVerified DateTime? @map("email_verified")
|
||||
image String?
|
||||
timeZone String? @map("time_zone")
|
||||
weekStart Int? @map("week_start")
|
||||
timeFormat TimeFormat? @map("time_format")
|
||||
locale String?
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime? @updatedAt @map("updated_at")
|
||||
customerId String? @map("customer_id")
|
||||
banned Boolean @default(false)
|
||||
bannedAt DateTime? @map("banned_at")
|
||||
banReason String? @map("ban_reason")
|
||||
role UserRole @default(user)
|
||||
|
||||
comments Comment[]
|
||||
polls Poll[]
|
||||
|
@ -58,7 +58,8 @@ model User {
|
|||
paymentMethods PaymentMethod[]
|
||||
subscription Subscription? @relation("UserToSubscription")
|
||||
|
||||
spaces Space[] @relation("UserSpaces")
|
||||
spaces Space[] @relation("UserSpaces")
|
||||
memberOf SpaceMember[]
|
||||
|
||||
pollViews PollView[]
|
||||
scheduledEvents ScheduledEvent[]
|
||||
|
@ -67,22 +68,6 @@ model User {
|
|||
@@map("users")
|
||||
}
|
||||
|
||||
model Space {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
ownerId String @map("owner_id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
owner User @relation("UserSpaces", fields: [ownerId], references: [id], onDelete: Cascade)
|
||||
polls Poll[]
|
||||
scheduledEvents ScheduledEvent[]
|
||||
subscription Subscription? @relation("SpaceToSubscription")
|
||||
|
||||
@@index([ownerId], type: Hash)
|
||||
@@map("spaces")
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
identifier String @db.Citext
|
||||
token String @unique
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue