@@ -17,45 +17,66 @@ model User {
1717 allergies String ?
1818 mobile String ?
1919 emailVerified DateTime ?
20- createdAt DateTime @default (now () )
21- updatedAt DateTime @updatedAt // is also updated manually
22- image Image ? @relation (fields : [imageId ] , references : [id ] )
20+ image Image ? @relation (fields : [imageId ] , references : [id ] ) // TODO: Rename to "profilePicture"?
2321 imageId Int ?
2422 studentCard String ? @unique
23+
24+ createdAt DateTime @default (now () )
25+ updatedAt DateTime @updatedAt // is also updated manually
2526
27+ // Authentication info used for logging in.
2628 credentials Credentials ?
2729 feideAccount FeideAccount ?
2830
31+ // Memberships to groups (committees, interest groups, classes, etc...).
2932 memberships Membership []
3033
34+ // Lockers used by the user.
3135 LockerReservation LockerReservation []
36+
37+ // Omega quotes posted by the user.
3238 omegaQuote OmegaQuote []
3339
40+ // Which ledger account (i.e. internal bank account) and
41+ // stripe customer this user is associated with.
3442 ledgerAccount LedgerAccount ?
43+ stripeCustomer StripeCustomer ?
3544
45+ // What notifications the user whiches to received and
46+ // which mailing lists the user is on.
3647 notificationSubscriptions NotificationSubscription []
3748 mailingLists MailingListUser []
3849
50+ // Which admissions (a.k.a. "opptak") the user has taken
51+ // and which admissions thay have registered for others.
3952 admissionTrials AdmissionTrial [] @relation (name : " user " )
4053 registeredAdmissionTrial AdmissionTrial [] @relation (name : " registeredBy " )
4154
55+ // The user's applications to committees.
4256 Application Application []
4357
58+ // Which events the user has registered for
59+ // and which events they have created.
4460 EventRegistration EventRegistration []
4561 Event Event []
4662
63+ // Which dots (a.k.a. "prikker") the user has received and given.
4764 dots DotWrapper [] @relation (name : " dot_user " )
4865 dotsAccused DotWrapper [] @relation (name : " dot_accuser " )
4966
67+ // The queue used to determine who is registering cards at Kiogeskabet.
5068 registerStudentCardQueue RegisterStudentCardQueue []
5169
70+ // Which cabin bookings the user has made.
5271 cabinBooking Booking [] @relation ()
5372
5473 // We need to explicitly mark the combination of 'id', 'username' and 'email' as
5574 // unique to make the relation to 'Credentials' work.
5675 @@unique ([id , username , email ] )
5776}
5877
78+ // This model primaraly exists to keep the password hash separate from the user table.
79+ // This is to reduce the risk of leaking the password hashes..
5980model Credentials {
6081 user User @relation (fields : [userId , username , email ] , references : [id , username , email ] , onDelete : Cascade , onUpdate : Cascade )
6182 userId Int @unique
@@ -69,22 +90,36 @@ model Credentials {
6990 @@unique ([userId , username , email ] )
7091}
7192
93+ // Associates each user with their Feide account.
7294model FeideAccount {
7395 id String @id
7496 accessToken String @db.Text
7597 email String @unique
7698 expiresAt DateTime
7799 issuedAt DateTime
78- userId Int @unique
79100 user User @relation (fields : [userId ] , references : [id ] , onDelete : Cascade , onUpdate : Cascade )
101+ userId Int @unique
102+ }
103+
104+ // Associates each user with their Stripe customer id.
105+ model StripeCustomer {
106+ user User @relation (fields : [userId ] , references : [id ] , onDelete : Cascade , onUpdate : Cascade )
107+ userId Int @id
108+ customerId String @unique
109+
110+ createdAt DateTime @default (now () )
111+ updatedAt DateTime @updatedAt
80112}
81113
114+ // When a user wants to register their student card, they are put in this queue.
115+ // Then they must scan their card with the card reader at Kiogeskabet.
82116model RegisterStudentCardQueue {
83117 userId Int @id
84118 user User @relation (fields : [userId ] , references : [id ] , onDelete : Cascade )
85119 expiry DateTime
86120}
87121
122+ // TODO: Someone should add a comment for ContactDetails because I have noe idea what it is for. Is it for anonymous users?
88123model ContactDetails {
89124 id Int @id @default (autoincrement () )
90125 name String
0 commit comments