Showing
7 changed files
with
0 additions
and
929 deletions
1 | -# Migration `20200419160117-init` | ||
2 | - | ||
3 | -This migration has been generated by sdy at 4/19/2020, 4:01:17 PM. | ||
4 | -You can check out the [state of the schema](./schema.prisma) after the migration. | ||
5 | - | ||
6 | -## Database Steps | ||
7 | - | ||
8 | -```sql | ||
9 | -CREATE TABLE `chat_schema`.`User` ( | ||
10 | - `avatarUrl` varchar(191) , | ||
11 | - `bio` varchar(191) , | ||
12 | - `createdAt` datetime DEFAULT CURRENT_TIMESTAMP , | ||
13 | - `email` varchar(191) NOT NULL , | ||
14 | - `id` int NOT NULL AUTO_INCREMENT, | ||
15 | - `loginSecret` varchar(191) , | ||
16 | - `name` varchar(191) NOT NULL , | ||
17 | - `password` varchar(191) NOT NULL , | ||
18 | - PRIMARY KEY (`id`) | ||
19 | -) | ||
20 | -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci | ||
21 | - | ||
22 | -CREATE TABLE `chat_schema`.`Room` ( | ||
23 | - `id` int NOT NULL AUTO_INCREMENT, | ||
24 | - PRIMARY KEY (`id`) | ||
25 | -) | ||
26 | -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci | ||
27 | - | ||
28 | -CREATE TABLE `chat_schema`.`Category` ( | ||
29 | - `id` int NOT NULL AUTO_INCREMENT, | ||
30 | - `name` varchar(191) DEFAULT '' , | ||
31 | - PRIMARY KEY (`id`) | ||
32 | -) | ||
33 | -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci | ||
34 | - | ||
35 | -CREATE TABLE `chat_schema`.`Message` ( | ||
36 | - `id` int NOT NULL AUTO_INCREMENT, | ||
37 | - `senderId` int NOT NULL , | ||
38 | - `text` varchar(191) DEFAULT '' , | ||
39 | - PRIMARY KEY (`id`) | ||
40 | -) | ||
41 | -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci | ||
42 | - | ||
43 | -CREATE TABLE `chat_schema`.`_RoomToUser` ( | ||
44 | - `A` int NOT NULL , | ||
45 | - `B` int NOT NULL | ||
46 | -) | ||
47 | -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci | ||
48 | - | ||
49 | -CREATE TABLE `chat_schema`.`_CategoryToRoom` ( | ||
50 | - `A` int NOT NULL , | ||
51 | - `B` int NOT NULL | ||
52 | -) | ||
53 | -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci | ||
54 | - | ||
55 | -CREATE UNIQUE INDEX `User.email` ON `chat_schema`.`User`(`email`) | ||
56 | - | ||
57 | -CREATE UNIQUE INDEX `_RoomToUser_AB_unique` ON `chat_schema`.`_RoomToUser`(`A`,`B`) | ||
58 | - | ||
59 | -CREATE INDEX `_RoomToUser_B_index` ON `chat_schema`.`_RoomToUser`(`B`) | ||
60 | - | ||
61 | -CREATE UNIQUE INDEX `_CategoryToRoom_AB_unique` ON `chat_schema`.`_CategoryToRoom`(`A`,`B`) | ||
62 | - | ||
63 | -CREATE INDEX `_CategoryToRoom_B_index` ON `chat_schema`.`_CategoryToRoom`(`B`) | ||
64 | - | ||
65 | -ALTER TABLE `chat_schema`.`Message` ADD FOREIGN KEY (`senderId`) REFERENCES `chat_schema`.`User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE | ||
66 | - | ||
67 | -ALTER TABLE `chat_schema`.`_RoomToUser` ADD FOREIGN KEY (`A`) REFERENCES `chat_schema`.`Room`(`id`) ON DELETE CASCADE ON UPDATE CASCADE | ||
68 | - | ||
69 | -ALTER TABLE `chat_schema`.`_RoomToUser` ADD FOREIGN KEY (`B`) REFERENCES `chat_schema`.`User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE | ||
70 | - | ||
71 | -ALTER TABLE `chat_schema`.`_CategoryToRoom` ADD FOREIGN KEY (`A`) REFERENCES `chat_schema`.`Category`(`id`) ON DELETE CASCADE ON UPDATE CASCADE | ||
72 | - | ||
73 | -ALTER TABLE `chat_schema`.`_CategoryToRoom` ADD FOREIGN KEY (`B`) REFERENCES `chat_schema`.`Room`(`id`) ON DELETE CASCADE ON UPDATE CASCADE | ||
74 | - | ||
75 | -DROP TABLE `chat_schema`.`_migration`; | ||
76 | - | ||
77 | -DROP TABLE `chat_schema`.`test`; | ||
78 | -``` | ||
79 | - | ||
80 | -## Changes | ||
81 | - | ||
82 | -```diff | ||
83 | -diff --git schema.prisma schema.prisma | ||
84 | -migration ..20200419160117-init | ||
85 | ---- datamodel.dml | ||
86 | -+++ datamodel.dml | ||
87 | -@@ -1,0 +1,41 @@ | ||
88 | -+generator client { | ||
89 | -+ provider = "prisma-client-js" | ||
90 | -+ binaryTargets = ["native", "debian-openssl-1.1.x"] | ||
91 | -+} | ||
92 | -+ | ||
93 | -+datasource db { | ||
94 | -+ provider = "mysql" | ||
95 | -+ url = env("DATABASE_URL") | ||
96 | -+} | ||
97 | -+ | ||
98 | -+model User { | ||
99 | -+ id Int @default(autoincrement()) @id | ||
100 | -+ avatarUrl String? | ||
101 | -+ email String @unique | ||
102 | -+ password String | ||
103 | -+ name String | ||
104 | -+ loginSecret String? | ||
105 | -+ bio String? | ||
106 | -+ rooms Room[] @relation(references: [id]) | ||
107 | -+ messages Message[] | ||
108 | -+ createdAt DateTime? @default(now()) | ||
109 | -+} | ||
110 | -+ | ||
111 | -+model Room { | ||
112 | -+ id Int @default(autoincrement()) @id | ||
113 | -+ participants User[] @relation(references: [id]) | ||
114 | -+ categories Category[] @relation(references: [id]) | ||
115 | -+} | ||
116 | -+ | ||
117 | -+model Category { | ||
118 | -+ id Int @default(autoincrement()) @id | ||
119 | -+ name String? @default("") | ||
120 | -+ rooms Room[] @relation(references: [id]) | ||
121 | -+} | ||
122 | -+ | ||
123 | -+model Message { | ||
124 | -+ id Int @default(autoincrement()) @id | ||
125 | -+ text String? @default("") | ||
126 | -+ sender User @relation(fields: [senderId], references: [id]) | ||
127 | -+ senderId Int | ||
128 | -+} | ||
129 | -``` | ||
130 | - | ||
131 | - |
1 | -generator client { | ||
2 | - provider = "prisma-client-js" | ||
3 | - binaryTargets = ["native", "debian-openssl-1.1.x"] | ||
4 | -} | ||
5 | - | ||
6 | -datasource db { | ||
7 | - provider = "mysql" | ||
8 | - url = "***" | ||
9 | -} | ||
10 | - | ||
11 | -model User { | ||
12 | - id Int @default(autoincrement()) @id | ||
13 | - avatarUrl String? | ||
14 | - email String @unique | ||
15 | - password String | ||
16 | - name String | ||
17 | - loginSecret String? | ||
18 | - bio String? | ||
19 | - rooms Room[] @relation(references: [id]) | ||
20 | - messages Message[] | ||
21 | - createdAt DateTime? @default(now()) | ||
22 | -} | ||
23 | - | ||
24 | -model Room { | ||
25 | - id Int @default(autoincrement()) @id | ||
26 | - participants User[] @relation(references: [id]) | ||
27 | - categories Category[] @relation(references: [id]) | ||
28 | -} | ||
29 | - | ||
30 | -model Category { | ||
31 | - id Int @default(autoincrement()) @id | ||
32 | - name String? @default("") | ||
33 | - rooms Room[] @relation(references: [id]) | ||
34 | -} | ||
35 | - | ||
36 | -model Message { | ||
37 | - id Int @default(autoincrement()) @id | ||
38 | - text String? @default("") | ||
39 | - sender User @relation(fields: [senderId], references: [id]) | ||
40 | - senderId Int | ||
41 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -{ | ||
2 | - "version": "0.3.14-fixed", | ||
3 | - "steps": [ | ||
4 | - { | ||
5 | - "tag": "CreateSource", | ||
6 | - "source": "db" | ||
7 | - }, | ||
8 | - { | ||
9 | - "tag": "CreateArgument", | ||
10 | - "location": { | ||
11 | - "tag": "Source", | ||
12 | - "source": "db" | ||
13 | - }, | ||
14 | - "argument": "provider", | ||
15 | - "value": "\"mysql\"" | ||
16 | - }, | ||
17 | - { | ||
18 | - "tag": "CreateArgument", | ||
19 | - "location": { | ||
20 | - "tag": "Source", | ||
21 | - "source": "db" | ||
22 | - }, | ||
23 | - "argument": "url", | ||
24 | - "value": "env(\"DATABASE_URL\")" | ||
25 | - }, | ||
26 | - { | ||
27 | - "tag": "CreateModel", | ||
28 | - "model": "User" | ||
29 | - }, | ||
30 | - { | ||
31 | - "tag": "CreateField", | ||
32 | - "model": "User", | ||
33 | - "field": "id", | ||
34 | - "type": "Int", | ||
35 | - "arity": "Required" | ||
36 | - }, | ||
37 | - { | ||
38 | - "tag": "CreateDirective", | ||
39 | - "location": { | ||
40 | - "path": { | ||
41 | - "tag": "Field", | ||
42 | - "model": "User", | ||
43 | - "field": "id" | ||
44 | - }, | ||
45 | - "directive": "default" | ||
46 | - } | ||
47 | - }, | ||
48 | - { | ||
49 | - "tag": "CreateArgument", | ||
50 | - "location": { | ||
51 | - "tag": "Directive", | ||
52 | - "path": { | ||
53 | - "tag": "Field", | ||
54 | - "model": "User", | ||
55 | - "field": "id" | ||
56 | - }, | ||
57 | - "directive": "default" | ||
58 | - }, | ||
59 | - "argument": "", | ||
60 | - "value": "autoincrement()" | ||
61 | - }, | ||
62 | - { | ||
63 | - "tag": "CreateDirective", | ||
64 | - "location": { | ||
65 | - "path": { | ||
66 | - "tag": "Field", | ||
67 | - "model": "User", | ||
68 | - "field": "id" | ||
69 | - }, | ||
70 | - "directive": "id" | ||
71 | - } | ||
72 | - }, | ||
73 | - { | ||
74 | - "tag": "CreateField", | ||
75 | - "model": "User", | ||
76 | - "field": "avatarUrl", | ||
77 | - "type": "String", | ||
78 | - "arity": "Optional" | ||
79 | - }, | ||
80 | - { | ||
81 | - "tag": "CreateField", | ||
82 | - "model": "User", | ||
83 | - "field": "email", | ||
84 | - "type": "String", | ||
85 | - "arity": "Required" | ||
86 | - }, | ||
87 | - { | ||
88 | - "tag": "CreateDirective", | ||
89 | - "location": { | ||
90 | - "path": { | ||
91 | - "tag": "Field", | ||
92 | - "model": "User", | ||
93 | - "field": "email" | ||
94 | - }, | ||
95 | - "directive": "unique" | ||
96 | - } | ||
97 | - }, | ||
98 | - { | ||
99 | - "tag": "CreateField", | ||
100 | - "model": "User", | ||
101 | - "field": "password", | ||
102 | - "type": "String", | ||
103 | - "arity": "Required" | ||
104 | - }, | ||
105 | - { | ||
106 | - "tag": "CreateField", | ||
107 | - "model": "User", | ||
108 | - "field": "name", | ||
109 | - "type": "String", | ||
110 | - "arity": "Required" | ||
111 | - }, | ||
112 | - { | ||
113 | - "tag": "CreateField", | ||
114 | - "model": "User", | ||
115 | - "field": "loginSecret", | ||
116 | - "type": "String", | ||
117 | - "arity": "Optional" | ||
118 | - }, | ||
119 | - { | ||
120 | - "tag": "CreateField", | ||
121 | - "model": "User", | ||
122 | - "field": "bio", | ||
123 | - "type": "String", | ||
124 | - "arity": "Optional" | ||
125 | - }, | ||
126 | - { | ||
127 | - "tag": "CreateField", | ||
128 | - "model": "User", | ||
129 | - "field": "rooms", | ||
130 | - "type": "Room", | ||
131 | - "arity": "List" | ||
132 | - }, | ||
133 | - { | ||
134 | - "tag": "CreateDirective", | ||
135 | - "location": { | ||
136 | - "path": { | ||
137 | - "tag": "Field", | ||
138 | - "model": "User", | ||
139 | - "field": "rooms" | ||
140 | - }, | ||
141 | - "directive": "relation" | ||
142 | - } | ||
143 | - }, | ||
144 | - { | ||
145 | - "tag": "CreateArgument", | ||
146 | - "location": { | ||
147 | - "tag": "Directive", | ||
148 | - "path": { | ||
149 | - "tag": "Field", | ||
150 | - "model": "User", | ||
151 | - "field": "rooms" | ||
152 | - }, | ||
153 | - "directive": "relation" | ||
154 | - }, | ||
155 | - "argument": "references", | ||
156 | - "value": "[id]" | ||
157 | - }, | ||
158 | - { | ||
159 | - "tag": "CreateField", | ||
160 | - "model": "User", | ||
161 | - "field": "messages", | ||
162 | - "type": "Message", | ||
163 | - "arity": "List" | ||
164 | - }, | ||
165 | - { | ||
166 | - "tag": "CreateField", | ||
167 | - "model": "User", | ||
168 | - "field": "createdAt", | ||
169 | - "type": "DateTime", | ||
170 | - "arity": "Optional" | ||
171 | - }, | ||
172 | - { | ||
173 | - "tag": "CreateDirective", | ||
174 | - "location": { | ||
175 | - "path": { | ||
176 | - "tag": "Field", | ||
177 | - "model": "User", | ||
178 | - "field": "createdAt" | ||
179 | - }, | ||
180 | - "directive": "default" | ||
181 | - } | ||
182 | - }, | ||
183 | - { | ||
184 | - "tag": "CreateArgument", | ||
185 | - "location": { | ||
186 | - "tag": "Directive", | ||
187 | - "path": { | ||
188 | - "tag": "Field", | ||
189 | - "model": "User", | ||
190 | - "field": "createdAt" | ||
191 | - }, | ||
192 | - "directive": "default" | ||
193 | - }, | ||
194 | - "argument": "", | ||
195 | - "value": "now()" | ||
196 | - }, | ||
197 | - { | ||
198 | - "tag": "CreateModel", | ||
199 | - "model": "Room" | ||
200 | - }, | ||
201 | - { | ||
202 | - "tag": "CreateField", | ||
203 | - "model": "Room", | ||
204 | - "field": "id", | ||
205 | - "type": "Int", | ||
206 | - "arity": "Required" | ||
207 | - }, | ||
208 | - { | ||
209 | - "tag": "CreateDirective", | ||
210 | - "location": { | ||
211 | - "path": { | ||
212 | - "tag": "Field", | ||
213 | - "model": "Room", | ||
214 | - "field": "id" | ||
215 | - }, | ||
216 | - "directive": "default" | ||
217 | - } | ||
218 | - }, | ||
219 | - { | ||
220 | - "tag": "CreateArgument", | ||
221 | - "location": { | ||
222 | - "tag": "Directive", | ||
223 | - "path": { | ||
224 | - "tag": "Field", | ||
225 | - "model": "Room", | ||
226 | - "field": "id" | ||
227 | - }, | ||
228 | - "directive": "default" | ||
229 | - }, | ||
230 | - "argument": "", | ||
231 | - "value": "autoincrement()" | ||
232 | - }, | ||
233 | - { | ||
234 | - "tag": "CreateDirective", | ||
235 | - "location": { | ||
236 | - "path": { | ||
237 | - "tag": "Field", | ||
238 | - "model": "Room", | ||
239 | - "field": "id" | ||
240 | - }, | ||
241 | - "directive": "id" | ||
242 | - } | ||
243 | - }, | ||
244 | - { | ||
245 | - "tag": "CreateField", | ||
246 | - "model": "Room", | ||
247 | - "field": "participants", | ||
248 | - "type": "User", | ||
249 | - "arity": "List" | ||
250 | - }, | ||
251 | - { | ||
252 | - "tag": "CreateDirective", | ||
253 | - "location": { | ||
254 | - "path": { | ||
255 | - "tag": "Field", | ||
256 | - "model": "Room", | ||
257 | - "field": "participants" | ||
258 | - }, | ||
259 | - "directive": "relation" | ||
260 | - } | ||
261 | - }, | ||
262 | - { | ||
263 | - "tag": "CreateArgument", | ||
264 | - "location": { | ||
265 | - "tag": "Directive", | ||
266 | - "path": { | ||
267 | - "tag": "Field", | ||
268 | - "model": "Room", | ||
269 | - "field": "participants" | ||
270 | - }, | ||
271 | - "directive": "relation" | ||
272 | - }, | ||
273 | - "argument": "references", | ||
274 | - "value": "[id]" | ||
275 | - }, | ||
276 | - { | ||
277 | - "tag": "CreateField", | ||
278 | - "model": "Room", | ||
279 | - "field": "categories", | ||
280 | - "type": "Category", | ||
281 | - "arity": "List" | ||
282 | - }, | ||
283 | - { | ||
284 | - "tag": "CreateDirective", | ||
285 | - "location": { | ||
286 | - "path": { | ||
287 | - "tag": "Field", | ||
288 | - "model": "Room", | ||
289 | - "field": "categories" | ||
290 | - }, | ||
291 | - "directive": "relation" | ||
292 | - } | ||
293 | - }, | ||
294 | - { | ||
295 | - "tag": "CreateArgument", | ||
296 | - "location": { | ||
297 | - "tag": "Directive", | ||
298 | - "path": { | ||
299 | - "tag": "Field", | ||
300 | - "model": "Room", | ||
301 | - "field": "categories" | ||
302 | - }, | ||
303 | - "directive": "relation" | ||
304 | - }, | ||
305 | - "argument": "references", | ||
306 | - "value": "[id]" | ||
307 | - }, | ||
308 | - { | ||
309 | - "tag": "CreateModel", | ||
310 | - "model": "Category" | ||
311 | - }, | ||
312 | - { | ||
313 | - "tag": "CreateField", | ||
314 | - "model": "Category", | ||
315 | - "field": "id", | ||
316 | - "type": "Int", | ||
317 | - "arity": "Required" | ||
318 | - }, | ||
319 | - { | ||
320 | - "tag": "CreateDirective", | ||
321 | - "location": { | ||
322 | - "path": { | ||
323 | - "tag": "Field", | ||
324 | - "model": "Category", | ||
325 | - "field": "id" | ||
326 | - }, | ||
327 | - "directive": "default" | ||
328 | - } | ||
329 | - }, | ||
330 | - { | ||
331 | - "tag": "CreateArgument", | ||
332 | - "location": { | ||
333 | - "tag": "Directive", | ||
334 | - "path": { | ||
335 | - "tag": "Field", | ||
336 | - "model": "Category", | ||
337 | - "field": "id" | ||
338 | - }, | ||
339 | - "directive": "default" | ||
340 | - }, | ||
341 | - "argument": "", | ||
342 | - "value": "autoincrement()" | ||
343 | - }, | ||
344 | - { | ||
345 | - "tag": "CreateDirective", | ||
346 | - "location": { | ||
347 | - "path": { | ||
348 | - "tag": "Field", | ||
349 | - "model": "Category", | ||
350 | - "field": "id" | ||
351 | - }, | ||
352 | - "directive": "id" | ||
353 | - } | ||
354 | - }, | ||
355 | - { | ||
356 | - "tag": "CreateField", | ||
357 | - "model": "Category", | ||
358 | - "field": "name", | ||
359 | - "type": "String", | ||
360 | - "arity": "Optional" | ||
361 | - }, | ||
362 | - { | ||
363 | - "tag": "CreateDirective", | ||
364 | - "location": { | ||
365 | - "path": { | ||
366 | - "tag": "Field", | ||
367 | - "model": "Category", | ||
368 | - "field": "name" | ||
369 | - }, | ||
370 | - "directive": "default" | ||
371 | - } | ||
372 | - }, | ||
373 | - { | ||
374 | - "tag": "CreateArgument", | ||
375 | - "location": { | ||
376 | - "tag": "Directive", | ||
377 | - "path": { | ||
378 | - "tag": "Field", | ||
379 | - "model": "Category", | ||
380 | - "field": "name" | ||
381 | - }, | ||
382 | - "directive": "default" | ||
383 | - }, | ||
384 | - "argument": "", | ||
385 | - "value": "\"\"" | ||
386 | - }, | ||
387 | - { | ||
388 | - "tag": "CreateField", | ||
389 | - "model": "Category", | ||
390 | - "field": "rooms", | ||
391 | - "type": "Room", | ||
392 | - "arity": "List" | ||
393 | - }, | ||
394 | - { | ||
395 | - "tag": "CreateDirective", | ||
396 | - "location": { | ||
397 | - "path": { | ||
398 | - "tag": "Field", | ||
399 | - "model": "Category", | ||
400 | - "field": "rooms" | ||
401 | - }, | ||
402 | - "directive": "relation" | ||
403 | - } | ||
404 | - }, | ||
405 | - { | ||
406 | - "tag": "CreateArgument", | ||
407 | - "location": { | ||
408 | - "tag": "Directive", | ||
409 | - "path": { | ||
410 | - "tag": "Field", | ||
411 | - "model": "Category", | ||
412 | - "field": "rooms" | ||
413 | - }, | ||
414 | - "directive": "relation" | ||
415 | - }, | ||
416 | - "argument": "references", | ||
417 | - "value": "[id]" | ||
418 | - }, | ||
419 | - { | ||
420 | - "tag": "CreateModel", | ||
421 | - "model": "Message" | ||
422 | - }, | ||
423 | - { | ||
424 | - "tag": "CreateField", | ||
425 | - "model": "Message", | ||
426 | - "field": "id", | ||
427 | - "type": "Int", | ||
428 | - "arity": "Required" | ||
429 | - }, | ||
430 | - { | ||
431 | - "tag": "CreateDirective", | ||
432 | - "location": { | ||
433 | - "path": { | ||
434 | - "tag": "Field", | ||
435 | - "model": "Message", | ||
436 | - "field": "id" | ||
437 | - }, | ||
438 | - "directive": "default" | ||
439 | - } | ||
440 | - }, | ||
441 | - { | ||
442 | - "tag": "CreateArgument", | ||
443 | - "location": { | ||
444 | - "tag": "Directive", | ||
445 | - "path": { | ||
446 | - "tag": "Field", | ||
447 | - "model": "Message", | ||
448 | - "field": "id" | ||
449 | - }, | ||
450 | - "directive": "default" | ||
451 | - }, | ||
452 | - "argument": "", | ||
453 | - "value": "autoincrement()" | ||
454 | - }, | ||
455 | - { | ||
456 | - "tag": "CreateDirective", | ||
457 | - "location": { | ||
458 | - "path": { | ||
459 | - "tag": "Field", | ||
460 | - "model": "Message", | ||
461 | - "field": "id" | ||
462 | - }, | ||
463 | - "directive": "id" | ||
464 | - } | ||
465 | - }, | ||
466 | - { | ||
467 | - "tag": "CreateField", | ||
468 | - "model": "Message", | ||
469 | - "field": "text", | ||
470 | - "type": "String", | ||
471 | - "arity": "Optional" | ||
472 | - }, | ||
473 | - { | ||
474 | - "tag": "CreateDirective", | ||
475 | - "location": { | ||
476 | - "path": { | ||
477 | - "tag": "Field", | ||
478 | - "model": "Message", | ||
479 | - "field": "text" | ||
480 | - }, | ||
481 | - "directive": "default" | ||
482 | - } | ||
483 | - }, | ||
484 | - { | ||
485 | - "tag": "CreateArgument", | ||
486 | - "location": { | ||
487 | - "tag": "Directive", | ||
488 | - "path": { | ||
489 | - "tag": "Field", | ||
490 | - "model": "Message", | ||
491 | - "field": "text" | ||
492 | - }, | ||
493 | - "directive": "default" | ||
494 | - }, | ||
495 | - "argument": "", | ||
496 | - "value": "\"\"" | ||
497 | - }, | ||
498 | - { | ||
499 | - "tag": "CreateField", | ||
500 | - "model": "Message", | ||
501 | - "field": "sender", | ||
502 | - "type": "User", | ||
503 | - "arity": "Required" | ||
504 | - }, | ||
505 | - { | ||
506 | - "tag": "CreateDirective", | ||
507 | - "location": { | ||
508 | - "path": { | ||
509 | - "tag": "Field", | ||
510 | - "model": "Message", | ||
511 | - "field": "sender" | ||
512 | - }, | ||
513 | - "directive": "relation" | ||
514 | - } | ||
515 | - }, | ||
516 | - { | ||
517 | - "tag": "CreateArgument", | ||
518 | - "location": { | ||
519 | - "tag": "Directive", | ||
520 | - "path": { | ||
521 | - "tag": "Field", | ||
522 | - "model": "Message", | ||
523 | - "field": "sender" | ||
524 | - }, | ||
525 | - "directive": "relation" | ||
526 | - }, | ||
527 | - "argument": "fields", | ||
528 | - "value": "[senderId]" | ||
529 | - }, | ||
530 | - { | ||
531 | - "tag": "CreateArgument", | ||
532 | - "location": { | ||
533 | - "tag": "Directive", | ||
534 | - "path": { | ||
535 | - "tag": "Field", | ||
536 | - "model": "Message", | ||
537 | - "field": "sender" | ||
538 | - }, | ||
539 | - "directive": "relation" | ||
540 | - }, | ||
541 | - "argument": "references", | ||
542 | - "value": "[id]" | ||
543 | - }, | ||
544 | - { | ||
545 | - "tag": "CreateField", | ||
546 | - "model": "Message", | ||
547 | - "field": "senderId", | ||
548 | - "type": "Int", | ||
549 | - "arity": "Required" | ||
550 | - } | ||
551 | - ] | ||
552 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -# Migration `20200424124259-init` | ||
2 | - | ||
3 | -This migration has been generated by sdy at 4/24/2020, 12:42:59 PM. | ||
4 | -You can check out the [state of the schema](./schema.prisma) after the migration. | ||
5 | - | ||
6 | -## Database Steps | ||
7 | - | ||
8 | -```sql | ||
9 | -CREATE TABLE `chat_schema`.`User` ( | ||
10 | - `avatarUrl` varchar(191) , | ||
11 | - `bio` varchar(191) , | ||
12 | - `createdAt` datetime DEFAULT CURRENT_TIMESTAMP , | ||
13 | - `email` varchar(191) NOT NULL , | ||
14 | - `emailSecret` varchar(191) , | ||
15 | - `id` int NOT NULL AUTO_INCREMENT, | ||
16 | - `name` varchar(191) NOT NULL , | ||
17 | - `password` varchar(191) NOT NULL , | ||
18 | - `phoneNumber` int , | ||
19 | - `phoneSecret` varchar(191) , | ||
20 | - PRIMARY KEY (`id`) | ||
21 | -) | ||
22 | -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci | ||
23 | - | ||
24 | -CREATE TABLE `chat_schema`.`Room` ( | ||
25 | - `id` int NOT NULL AUTO_INCREMENT, | ||
26 | - PRIMARY KEY (`id`) | ||
27 | -) | ||
28 | -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci | ||
29 | - | ||
30 | -CREATE TABLE `chat_schema`.`Category` ( | ||
31 | - `id` int NOT NULL AUTO_INCREMENT, | ||
32 | - `name` varchar(191) DEFAULT '' , | ||
33 | - PRIMARY KEY (`id`) | ||
34 | -) | ||
35 | -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci | ||
36 | - | ||
37 | -CREATE TABLE `chat_schema`.`Message` ( | ||
38 | - `id` int NOT NULL AUTO_INCREMENT, | ||
39 | - `senderId` int NOT NULL , | ||
40 | - `text` varchar(191) DEFAULT '' , | ||
41 | - PRIMARY KEY (`id`) | ||
42 | -) | ||
43 | -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci | ||
44 | - | ||
45 | -CREATE TABLE `chat_schema`.`_RoomToUser` ( | ||
46 | - `A` int NOT NULL , | ||
47 | - `B` int NOT NULL | ||
48 | -) | ||
49 | -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci | ||
50 | - | ||
51 | -CREATE TABLE `chat_schema`.`_CategoryToRoom` ( | ||
52 | - `A` int NOT NULL , | ||
53 | - `B` int NOT NULL | ||
54 | -) | ||
55 | -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci | ||
56 | - | ||
57 | -CREATE UNIQUE INDEX `User.email` ON `chat_schema`.`User`(`email`) | ||
58 | - | ||
59 | -CREATE UNIQUE INDEX `_RoomToUser_AB_unique` ON `chat_schema`.`_RoomToUser`(`A`,`B`) | ||
60 | - | ||
61 | -CREATE INDEX `_RoomToUser_B_index` ON `chat_schema`.`_RoomToUser`(`B`) | ||
62 | - | ||
63 | -CREATE UNIQUE INDEX `_CategoryToRoom_AB_unique` ON `chat_schema`.`_CategoryToRoom`(`A`,`B`) | ||
64 | - | ||
65 | -CREATE INDEX `_CategoryToRoom_B_index` ON `chat_schema`.`_CategoryToRoom`(`B`) | ||
66 | - | ||
67 | -ALTER TABLE `chat_schema`.`Message` ADD FOREIGN KEY (`senderId`) REFERENCES `chat_schema`.`User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE | ||
68 | - | ||
69 | -ALTER TABLE `chat_schema`.`_RoomToUser` ADD FOREIGN KEY (`A`) REFERENCES `chat_schema`.`Room`(`id`) ON DELETE CASCADE ON UPDATE CASCADE | ||
70 | - | ||
71 | -ALTER TABLE `chat_schema`.`_RoomToUser` ADD FOREIGN KEY (`B`) REFERENCES `chat_schema`.`User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE | ||
72 | - | ||
73 | -ALTER TABLE `chat_schema`.`_CategoryToRoom` ADD FOREIGN KEY (`A`) REFERENCES `chat_schema`.`Category`(`id`) ON DELETE CASCADE ON UPDATE CASCADE | ||
74 | - | ||
75 | -ALTER TABLE `chat_schema`.`_CategoryToRoom` ADD FOREIGN KEY (`B`) REFERENCES `chat_schema`.`Room`(`id`) ON DELETE CASCADE ON UPDATE CASCADE | ||
76 | - | ||
77 | -DROP TABLE `chat_schema`.`_categorytoroom`; | ||
78 | - | ||
79 | -DROP TABLE `chat_schema`.`_migration`; | ||
80 | - | ||
81 | -DROP TABLE `chat_schema`.`_roomtouser`; | ||
82 | - | ||
83 | -DROP TABLE `chat_schema`.`category`; | ||
84 | - | ||
85 | -DROP TABLE `chat_schema`.`message`; | ||
86 | - | ||
87 | -DROP TABLE `chat_schema`.`room`; | ||
88 | - | ||
89 | -DROP TABLE `chat_schema`.`test`; | ||
90 | - | ||
91 | -DROP TABLE `chat_schema`.`user`; | ||
92 | -``` | ||
93 | - | ||
94 | -## Changes | ||
95 | - | ||
96 | -```diff | ||
97 | -diff --git schema.prisma schema.prisma | ||
98 | -migration 20200419160117-init..20200424124259-init | ||
99 | ---- datamodel.dml | ||
100 | -+++ datamodel.dml | ||
101 | -@@ -4,18 +4,20 @@ | ||
102 | - } | ||
103 | - datasource db { | ||
104 | - provider = "mysql" | ||
105 | -- url = "***" | ||
106 | -+ url = env("DATABASE_URL") | ||
107 | - } | ||
108 | - model User { | ||
109 | - id Int @default(autoincrement()) @id | ||
110 | - avatarUrl String? | ||
111 | - email String @unique | ||
112 | - password String | ||
113 | - name String | ||
114 | -- loginSecret String? | ||
115 | -+ phoneNumber Int? | ||
116 | -+ emailSecret String? | ||
117 | -+ phoneSecret String? | ||
118 | - bio String? | ||
119 | - rooms Room[] @relation(references: [id]) | ||
120 | - messages Message[] | ||
121 | - createdAt DateTime? @default(now()) | ||
122 | -``` | ||
123 | - | ||
124 | - |
1 | -generator client { | ||
2 | - provider = "prisma-client-js" | ||
3 | - binaryTargets = ["native", "debian-openssl-1.1.x"] | ||
4 | -} | ||
5 | - | ||
6 | -datasource db { | ||
7 | - provider = "mysql" | ||
8 | - url = "***" | ||
9 | -} | ||
10 | - | ||
11 | -model User { | ||
12 | - id Int @default(autoincrement()) @id | ||
13 | - avatarUrl String? | ||
14 | - email String @unique | ||
15 | - password String | ||
16 | - name String | ||
17 | - phoneNumber Int? | ||
18 | - emailSecret String? | ||
19 | - phoneSecret String? | ||
20 | - bio String? | ||
21 | - rooms Room[] @relation(references: [id]) | ||
22 | - messages Message[] | ||
23 | - createdAt DateTime? @default(now()) | ||
24 | -} | ||
25 | - | ||
26 | -model Room { | ||
27 | - id Int @default(autoincrement()) @id | ||
28 | - participants User[] @relation(references: [id]) | ||
29 | - categories Category[] @relation(references: [id]) | ||
30 | -} | ||
31 | - | ||
32 | -model Category { | ||
33 | - id Int @default(autoincrement()) @id | ||
34 | - name String? @default("") | ||
35 | - rooms Room[] @relation(references: [id]) | ||
36 | -} | ||
37 | - | ||
38 | -model Message { | ||
39 | - id Int @default(autoincrement()) @id | ||
40 | - text String? @default("") | ||
41 | - sender User @relation(fields: [senderId], references: [id]) | ||
42 | - senderId Int | ||
43 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -{ | ||
2 | - "version": "0.3.14-fixed", | ||
3 | - "steps": [ | ||
4 | - { | ||
5 | - "tag": "CreateField", | ||
6 | - "model": "User", | ||
7 | - "field": "phoneNumber", | ||
8 | - "type": "Int", | ||
9 | - "arity": "Optional" | ||
10 | - }, | ||
11 | - { | ||
12 | - "tag": "CreateField", | ||
13 | - "model": "User", | ||
14 | - "field": "emailSecret", | ||
15 | - "type": "String", | ||
16 | - "arity": "Optional" | ||
17 | - }, | ||
18 | - { | ||
19 | - "tag": "CreateField", | ||
20 | - "model": "User", | ||
21 | - "field": "phoneSecret", | ||
22 | - "type": "String", | ||
23 | - "arity": "Optional" | ||
24 | - }, | ||
25 | - { | ||
26 | - "tag": "DeleteField", | ||
27 | - "model": "User", | ||
28 | - "field": "loginSecret" | ||
29 | - } | ||
30 | - ] | ||
31 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
back/prisma/migrations/migrate.lock
deleted
100644 → 0
1 | -# IF THERE'S A GIT CONFLICT IN THIS FILE, DON'T SOLVE IT MANUALLY! | ||
2 | -# INSTEAD EXECUTE `prisma migrate fix` | ||
3 | -# Prisma Migrate lockfile v1 | ||
4 | -# Read more about conflict resolution here: TODO | ||
5 | - | ||
6 | -20200419160117-init | ||
7 | -20200424124259-init | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment