feat: add organization schema
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
model AuthIdentity {
|
||||
id String @id @default(uuid())
|
||||
email String @unique
|
||||
password String
|
||||
isVerified Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
organizationMemberships OrganizationUserMembership[]
|
||||
verifications AuthVerification[]
|
||||
sentInvitations OrganizationInvitation[]
|
||||
id String @id @default(uuid())
|
||||
email String @unique
|
||||
password String
|
||||
isVerified Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
memberships OrganizationMember[]
|
||||
verifications AuthVerification[]
|
||||
}
|
||||
|
||||
model AuthVerification {
|
||||
|
||||
42
prisma/schema/organization.prisma
Normal file
42
prisma/schema/organization.prisma
Normal file
@@ -0,0 +1,42 @@
|
||||
model OrganizationMember {
|
||||
id String @id @default(uuid())
|
||||
identityId String
|
||||
organizationId String
|
||||
roleId String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
identity AuthIdentity @relation(fields: [identityId], references: [id])
|
||||
organization Organization @relation(fields: [organizationId], references: [id])
|
||||
role OrganizationRole @relation(fields: [roleId], references: [id])
|
||||
}
|
||||
|
||||
model OrganizationRole {
|
||||
id String @id @default(uuid())
|
||||
organizationId String
|
||||
name String
|
||||
permissions Json
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
organization Organization @relation(fields: [organizationId], references: [id])
|
||||
members OrganizationMember[]
|
||||
}
|
||||
|
||||
model OrganizationInvite {
|
||||
id String @id @default(uuid())
|
||||
recipientEmail String
|
||||
organizationId String
|
||||
roleId String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
organization Organization @relation(fields: [organizationId], references: [id])
|
||||
}
|
||||
|
||||
model Organization {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
organizationRoles OrganizationRole[]
|
||||
organizationInvites OrganizationInvite[]
|
||||
members OrganizationMember[]
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
model OrganizationInvitation {
|
||||
id String @id @default(uuid())
|
||||
senderId String
|
||||
organizationId String
|
||||
inviteToken String
|
||||
emailRecipient String
|
||||
createdAt DateTime @default(now())
|
||||
acceptedAt DateTime?
|
||||
isAccepted Boolean @default(false)
|
||||
isRevoked Boolean @default(false)
|
||||
organization Organization @relation(fields: [organizationId], references: [id])
|
||||
inviteSender AuthIdentity @relation(fields: [senderId], references: [id])
|
||||
}
|
||||
|
||||
model Organization {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
createdAt DateTime @default(now())
|
||||
organizationUsers OrganizationUserMembership[]
|
||||
invitations OrganizationInvitation[]
|
||||
}
|
||||
|
||||
model OrganizationUserMembership {
|
||||
id String @id @default(uuid())
|
||||
organizationId String
|
||||
identityId String
|
||||
createdAt DateTime @default(now())
|
||||
organization Organization @relation(fields: [organizationId], references: [id])
|
||||
identity AuthIdentity @relation(fields: [identityId], references: [id])
|
||||
}
|
||||
|
||||
enum OrganizationRole {
|
||||
OWNER
|
||||
ADMIN
|
||||
MEMBER
|
||||
}
|
||||
Reference in New Issue
Block a user