File size: 3,485 Bytes
c6be938
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
generator client {
  provider = "prisma-client-js"
  output   = "./generated/client"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Account {
  id                String  @id
  user_id           String
  type              String
  provider          String
  providerAccountId String
  refresh_token     String?
  access_token      String?
  expires_at        Int?
  token_type        String?
  scope             String?
  id_token          String?
  session_state     String?
  User              User    @relation(fields: [user_id], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
}

model Session {
  id           String   @id
  sessionToken String   @unique
  expires      DateTime
  user_id      String
  User         User     @relation(fields: [user_id], references: [id], onDelete: Cascade)
}

model User {
  id              String          @id
  name            String?
  email           String?         @unique
  emailVerified   DateTime?
  image           String?
  full_name       String
  password        String?
  registration_id String?         @unique
  Account         Account[]
  Session         Session[]
  active_ticket   active_ticket[]
  chat_message    chat_message[]
  closed_ticket   closed_ticket[]
}

model VerificationToken {
  identifier String
  token      String   @unique
  expires    DateTime

  @@unique([identifier, token])
}

model active_ticket {
  id           Int          @id @default(autoincrement())
  subject      String
  category     String
  user_id      String
  opened_time  DateTime     @default(now())
  hostel_block String?
  room_no      String?
  contact_no   String?
  chat_id      Int
  body         String
  chat_history chat_history @relation(fields: [chat_id], references: [id])
  User         User         @relation(fields: [user_id], references: [id])
}

model admin {
  id          Int    @id @default(autoincrement())
  email       String @unique
  full_name   String
  password    String
  employee_id String @unique
}

model chat_history {
  id            Int             @id @default(autoincrement())
  active_ticket active_ticket[]
  chat_message  chat_message[]
  closed_ticket closed_ticket[]
}

model chat_message {
  id                   Int                @id @default(autoincrement())
  chat_history_id      Int
  body_text            String
  sent_time            DateTime           @default(now())
  user_id              String?
  complaint_manager_id Int?
  chat_history         chat_history       @relation(fields: [chat_history_id], references: [id])
  complaint_manager    complaint_manager? @relation(fields: [complaint_manager_id], references: [id])
  User                 User?              @relation(fields: [user_id], references: [id])
}

model closed_ticket {
  id           Int          @id @default(autoincrement())
  subject      String
  category     String
  user_id      String
  opened_time  DateTime
  hostel_block String?
  room_no      String?
  contact_no   String?
  closed_time  DateTime
  chat_id      Int
  body         String
  chat_history chat_history @relation(fields: [chat_id], references: [id])
  User         User         @relation(fields: [user_id], references: [id])
}

model complaint_manager {
  id           Int            @id @default(autoincrement())
  email        String         @unique
  full_name    String
  password     String
  employee_id  String         @unique
  chat_message chat_message[]
}