@virtality/schema 0.0.1-alpha.0.2 → 0.0.1-alpha.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virtality/schema",
3
- "version": "0.0.1-alpha.0.2",
3
+ "version": "0.0.1-alpha.0.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -0,0 +1,97 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `avatarId` on the `Patient` table. All the data in the column will be lost.
5
+
6
+ */
7
+ -- DropForeignKey
8
+ ALTER TABLE "Account" DROP CONSTRAINT "account_userId_fkey";
9
+
10
+ -- DropForeignKey
11
+ ALTER TABLE "Device" DROP CONSTRAINT "devices_userId_fkey";
12
+
13
+ -- DropForeignKey
14
+ ALTER TABLE "Invitation" DROP CONSTRAINT "invitation_inviterId_fkey";
15
+
16
+ -- DropForeignKey
17
+ ALTER TABLE "Invitation" DROP CONSTRAINT "invitation_organizationId_fkey";
18
+
19
+ -- DropForeignKey
20
+ ALTER TABLE "Member" DROP CONSTRAINT "member_organizationId_fkey";
21
+
22
+ -- DropForeignKey
23
+ ALTER TABLE "Member" DROP CONSTRAINT "member_userId_fkey";
24
+
25
+ -- DropForeignKey
26
+ ALTER TABLE "Patient" DROP CONSTRAINT "Patient_avatarId_fkey";
27
+
28
+ -- DropForeignKey
29
+ ALTER TABLE "PatientProgram" DROP CONSTRAINT "PatientProgram_userId_fkey";
30
+
31
+ -- DropForeignKey
32
+ ALTER TABLE "PatientSession" DROP CONSTRAINT "PatientSession_programId_fkey";
33
+
34
+ -- DropForeignKey
35
+ ALTER TABLE "ProgramExercise" DROP CONSTRAINT "program_exercises_programId_fkey";
36
+
37
+ -- DropForeignKey
38
+ ALTER TABLE "Session" DROP CONSTRAINT "session_userId_fkey";
39
+
40
+ -- DropForeignKey
41
+ ALTER TABLE "SessionData" DROP CONSTRAINT "SessionData_sessionExerciseId_fkey";
42
+
43
+ -- DropForeignKey
44
+ ALTER TABLE "SessionExercise" DROP CONSTRAINT "SessionExercise_patientSessionId_fkey";
45
+
46
+ -- AlterTable
47
+ ALTER TABLE "Patient" DROP COLUMN "avatarId",
48
+ ADD COLUMN "deletedAt" TIMESTAMP(6),
49
+ ADD COLUMN "history" TEXT;
50
+
51
+ -- AlterTable
52
+ ALTER TABLE "PatientSession" ALTER COLUMN "programId" DROP NOT NULL;
53
+
54
+ -- AlterTable
55
+ ALTER TABLE "SessionData" ALTER COLUMN "sessionExerciseId" DROP NOT NULL;
56
+
57
+ -- AlterTable
58
+ ALTER TABLE "SessionExercise" ALTER COLUMN "patientSessionId" DROP NOT NULL;
59
+
60
+ -- AlterTable
61
+ ALTER TABLE "User" ADD COLUMN "deletedAt" TIMESTAMP(6);
62
+
63
+ -- AddForeignKey
64
+ ALTER TABLE "Account" ADD CONSTRAINT "account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
65
+
66
+ -- AddForeignKey
67
+ ALTER TABLE "Device" ADD CONSTRAINT "devices_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
68
+
69
+ -- AddForeignKey
70
+ ALTER TABLE "Invitation" ADD CONSTRAINT "invitation_inviterId_fkey" FOREIGN KEY ("inviterId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
71
+
72
+ -- AddForeignKey
73
+ ALTER TABLE "Invitation" ADD CONSTRAINT "invitation_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
74
+
75
+ -- AddForeignKey
76
+ ALTER TABLE "Member" ADD CONSTRAINT "member_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
77
+
78
+ -- AddForeignKey
79
+ ALTER TABLE "Member" ADD CONSTRAINT "member_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
80
+
81
+ -- AddForeignKey
82
+ ALTER TABLE "PatientProgram" ADD CONSTRAINT "PatientProgram_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
83
+
84
+ -- AddForeignKey
85
+ ALTER TABLE "ProgramExercise" ADD CONSTRAINT "program_exercises_programId_fkey" FOREIGN KEY ("programId") REFERENCES "PatientProgram"("id") ON DELETE CASCADE ON UPDATE CASCADE;
86
+
87
+ -- AddForeignKey
88
+ ALTER TABLE "Session" ADD CONSTRAINT "session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
89
+
90
+ -- AddForeignKey
91
+ ALTER TABLE "PatientSession" ADD CONSTRAINT "PatientSession_programId_fkey" FOREIGN KEY ("programId") REFERENCES "PatientProgram"("id") ON DELETE SET NULL ON UPDATE CASCADE;
92
+
93
+ -- AddForeignKey
94
+ ALTER TABLE "SessionExercise" ADD CONSTRAINT "SessionExercise_patientSessionId_fkey" FOREIGN KEY ("patientSessionId") REFERENCES "PatientSession"("id") ON DELETE SET NULL ON UPDATE CASCADE;
95
+
96
+ -- AddForeignKey
97
+ ALTER TABLE "SessionData" ADD CONSTRAINT "SessionData_sessionExerciseId_fkey" FOREIGN KEY ("sessionExerciseId") REFERENCES "SessionExercise"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -22,19 +22,19 @@ model Account {
22
22
  password String?
23
23
  createdAt DateTime @db.Timestamp(6)
24
24
  updatedAt DateTime @db.Timestamp(6)
25
- user User @relation(fields: [userId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "account_userId_fkey")
25
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "account_userId_fkey")
26
26
  }
27
27
 
28
28
  model Device {
29
29
  id String @id(map: "devices_pkey")
30
- deviceId String?
31
30
  userId String
31
+ deviceId String?
32
32
  model String?
33
33
  lastUsed DateTime @db.Timestamp(6)
34
34
  createdAt DateTime @db.Timestamp(6)
35
35
  deletedAt DateTime? @db.Timestamp(6)
36
36
  name String
37
- user User @relation(fields: [userId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "devices_userId_fkey")
37
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "devices_userId_fkey")
38
38
  }
39
39
 
40
40
  model Exercise {
@@ -60,8 +60,8 @@ model Invitation {
60
60
  status String
61
61
  expiresAt DateTime @db.Timestamp(6)
62
62
  inviterId String
63
- user User @relation(fields: [inviterId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "invitation_inviterId_fkey")
64
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "invitation_organizationId_fkey")
63
+ user User @relation(fields: [inviterId], references: [id], onDelete: Cascade, map: "invitation_inviterId_fkey")
64
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, map: "invitation_organizationId_fkey")
65
65
  }
66
66
 
67
67
  model Member {
@@ -70,8 +70,8 @@ model Member {
70
70
  userId String
71
71
  role String
72
72
  createdAt DateTime @db.Timestamp(6)
73
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "member_organizationId_fkey")
74
- user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "member_userId_fkey")
73
+ organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, map: "member_organizationId_fkey")
74
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "member_userId_fkey")
75
75
  }
76
76
 
77
77
  model Organization {
@@ -89,19 +89,19 @@ model Organization {
89
89
 
90
90
  model Patient {
91
91
  id String @id(map: "patients_pkey")
92
- userId String?
93
92
  name String
93
+ userId String?
94
94
  email String?
95
95
  phone String?
96
96
  dob String?
97
97
  sex String?
98
98
  weight String?
99
99
  height String?
100
+ history String?
101
+ image String? @unique
100
102
  createdAt DateTime @default(now()) @db.Timestamp(6)
101
103
  updatedAt DateTime @default(now()) @db.Timestamp(6)
102
- avatarId String?
103
- image String? @unique
104
- avatar Avatar? @relation(fields: [avatarId], references: [id])
104
+ deletedAt DateTime? @db.Timestamp(6)
105
105
  patientProgram PatientProgram[]
106
106
  }
107
107
 
@@ -110,8 +110,8 @@ model PatientProgram {
110
110
  name String
111
111
  userId String
112
112
  patientId String
113
- Patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade)
114
- User User @relation(fields: [userId], references: [id])
113
+ patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade)
114
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
115
115
  patientSession PatientSession[]
116
116
  programExercise ProgramExercise[]
117
117
  }
@@ -126,7 +126,7 @@ model ProgramExercise {
126
126
  holdTime Int @default(1)
127
127
  speed Float @default(1)
128
128
  exercise Exercise @relation(fields: [exerciseId], references: [id])
129
- patientProgram PatientProgram @relation(fields: [programId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "program_exercises_programId_fkey")
129
+ patientProgram PatientProgram @relation(fields: [programId], references: [id], onDelete: Cascade, map: "program_exercises_programId_fkey")
130
130
  }
131
131
 
132
132
  model Session {
@@ -140,7 +140,7 @@ model Session {
140
140
  userId String
141
141
  activeOrganizationId String?
142
142
  impersonatedBy String?
143
- user User @relation(fields: [userId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "session_userId_fkey")
143
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "session_userId_fkey")
144
144
  }
145
145
 
146
146
  model User {
@@ -151,6 +151,7 @@ model User {
151
151
  image String? @unique
152
152
  createdAt DateTime @db.Timestamp(6)
153
153
  updatedAt DateTime @db.Timestamp(6)
154
+ deletedAt DateTime? @db.Timestamp(6)
154
155
  phone String?
155
156
  stripeCustomerId String?
156
157
  banExpires DateTime?
@@ -175,10 +176,9 @@ model Verification {
175
176
  }
176
177
 
177
178
  model Avatar {
178
- id String @id
179
- name String
180
- image String? @unique
181
- Patient Patient[]
179
+ id String @id
180
+ name String
181
+ image String? @unique
182
182
  }
183
183
 
184
184
  model Map {
@@ -189,17 +189,17 @@ model Map {
189
189
 
190
190
  model PatientSession {
191
191
  id String @id
192
- programId String
192
+ programId String?
193
193
  createdAt DateTime @db.Timestamp(6)
194
194
  completedAt DateTime? @db.Timestamp(6)
195
195
  deletedAt DateTime? @db.Timestamp(6)
196
- program PatientProgram @relation(fields: [programId], references: [id])
196
+ program PatientProgram? @relation(fields: [programId], references: [id], onDelete: SetNull)
197
197
  sessionExercise SessionExercise[]
198
198
  }
199
199
 
200
200
  model SessionExercise {
201
- id String @id
202
- patientSessionId String
201
+ id String @id
202
+ patientSessionId String?
203
203
  exerciseId String
204
204
  sets Int
205
205
  reps Int
@@ -207,15 +207,15 @@ model SessionExercise {
207
207
  holdTime Int
208
208
  speed Float
209
209
  sessionData SessionData[]
210
- exercise Exercise @relation(fields: [exerciseId], references: [id])
211
- patientSession PatientSession @relation(fields: [patientSessionId], references: [id])
210
+ exercise Exercise @relation(fields: [exerciseId], references: [id])
211
+ patientSession PatientSession? @relation(fields: [patientSessionId], references: [id], onDelete: SetNull)
212
212
  }
213
213
 
214
214
  model SessionData {
215
- id String @id
216
- sessionExerciseId String
215
+ id String @id
216
+ sessionExerciseId String?
217
217
  value String
218
- sessionExercise SessionExercise @relation(fields: [sessionExerciseId], references: [id])
218
+ sessionExercise SessionExercise? @relation(fields: [sessionExerciseId], references: [id], onDelete: SetNull)
219
219
  }
220
220
 
221
221
  model Subscription {