feat(auth): setup base auth domain
This commit is contained in:
21
prisma/schema/auth.prisma
Normal file
21
prisma/schema/auth.prisma
Normal file
@@ -0,0 +1,21 @@
|
||||
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[]
|
||||
}
|
||||
|
||||
model AuthVerification {
|
||||
id String @id @default(uuid())
|
||||
identityId String
|
||||
magicToken String
|
||||
createdAt DateTime @default(now())
|
||||
acceptedAt DateTime?
|
||||
isAccepted Boolean @default(false)
|
||||
isRevoked Boolean @default(false)
|
||||
identity AuthIdentity @relation(fields: [identityId], references: [id])
|
||||
}
|
||||
36
prisma/schema/organizations.prisma
Normal file
36
prisma/schema/organizations.prisma
Normal file
@@ -0,0 +1,36 @@
|
||||
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
|
||||
}
|
||||
9
prisma/schema/schema.prisma
Normal file
9
prisma/schema/schema.prisma
Normal file
@@ -0,0 +1,9 @@
|
||||
generator client {
|
||||
provider = "prisma-client"
|
||||
output = "../../src/generated/prisma"
|
||||
previewFeatures = ["relationJoins"]
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
}
|
||||
Reference in New Issue
Block a user