Showing
7 changed files
with
0 additions
and
377 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 |
This diff is collapsed. Click to expand it.
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