add organization management and refine source repository view
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -14,6 +14,14 @@ enum UserRole {
|
||||
USER
|
||||
}
|
||||
|
||||
enum OrganizationType {
|
||||
COMPANY
|
||||
SCHOOL
|
||||
GOVERNMENT
|
||||
LAB
|
||||
OTHER
|
||||
}
|
||||
|
||||
enum LicenseCode {
|
||||
FREE
|
||||
EDU
|
||||
@@ -32,6 +40,7 @@ model User {
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz(3)
|
||||
userLicenses UserLicense[]
|
||||
refreshTokens RefreshToken[]
|
||||
affiliations UserAffiliation[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
@@ -79,3 +88,37 @@ model UserLicense {
|
||||
@@index([licenseId])
|
||||
@@map("user_licenses")
|
||||
}
|
||||
|
||||
model Organization {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
name String
|
||||
type OrganizationType @default(OTHER)
|
||||
domain String?
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz(3)
|
||||
affiliations UserAffiliation[]
|
||||
|
||||
@@unique([name, type])
|
||||
@@index([isActive, type])
|
||||
@@map("organizations")
|
||||
}
|
||||
|
||||
model UserAffiliation {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
userId String @map("user_id") @db.Uuid
|
||||
organizationId String @map("organization_id") @db.Uuid
|
||||
department String?
|
||||
position String?
|
||||
isPrimary Boolean @default(false) @map("is_primary")
|
||||
startsAt DateTime? @map("starts_at") @db.Timestamptz(3)
|
||||
endsAt DateTime? @map("ends_at") @db.Timestamptz(3)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz(3)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Restrict)
|
||||
|
||||
@@index([userId, isPrimary])
|
||||
@@index([organizationId])
|
||||
@@map("user_affiliations")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user