Skip to content

Commit ad7e910

Browse files
committed
Fixing db migration
1 parent 32fa824 commit ad7e910

File tree

6 files changed

+73
-546
lines changed

6 files changed

+73
-546
lines changed

packages/db/drizzle/0001_modern_mandrill.sql renamed to packages/db/drizzle/0000_common_miracleman.sql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
CREATE TYPE "public"."shape" AS ENUM('rectangle', 'diamond', 'circle', 'line', 'arrow', 'text', 'freeHand');--> statement-breakpoint
12
CREATE TABLE "chat" (
23
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
34
"serialNumber" serial NOT NULL,
@@ -47,11 +48,6 @@ CREATE TABLE "user" (
4748
CONSTRAINT "user_username_unique" UNIQUE("username")
4849
);
4950
--> statement-breakpoint
50-
DROP TABLE "Chat" CASCADE;--> statement-breakpoint
51-
DROP TABLE "Draw" CASCADE;--> statement-breakpoint
52-
DROP TABLE "_participants" CASCADE;--> statement-breakpoint
53-
DROP TABLE "Room" CASCADE;--> statement-breakpoint
54-
DROP TABLE "User" CASCADE;--> statement-breakpoint
5551
ALTER TABLE "chat" ADD CONSTRAINT "chat_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
5652
ALTER TABLE "chat" ADD CONSTRAINT "chat_roomId_room_id_fk" FOREIGN KEY ("roomId") REFERENCES "public"."room"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
5753
ALTER TABLE "draw" ADD CONSTRAINT "draw_roomId_room_id_fk" FOREIGN KEY ("roomId") REFERENCES "public"."room"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint

packages/db/drizzle/0000_normal_namora.sql

Lines changed: 0 additions & 56 deletions
This file was deleted.

packages/db/drizzle/meta/0000_snapshot.json

Lines changed: 69 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,25 @@
11
{
2-
"id": "2d5b0a57-97ac-4d5b-905a-d3c6ec78caa3",
2+
"id": "eb819080-df32-4840-9c03-0fcffd5f113f",
33
"prevId": "00000000-0000-0000-0000-000000000000",
44
"version": "7",
55
"dialect": "postgresql",
66
"tables": {
7-
"public.Chat": {
8-
"name": "Chat",
7+
"public.chat": {
8+
"name": "chat",
99
"schema": "",
1010
"columns": {
1111
"id": {
1212
"name": "id",
13-
"type": "text",
13+
"type": "uuid",
1414
"primaryKey": true,
15-
"notNull": true
15+
"notNull": true,
16+
"default": "gen_random_uuid()"
1617
},
1718
"serialNumber": {
1819
"name": "serialNumber",
19-
"type": "integer",
20+
"type": "serial",
2021
"primaryKey": false,
21-
"notNull": true,
22-
"identity": {
23-
"type": "always",
24-
"name": "Chat_serialNumber_seq",
25-
"schema": "public",
26-
"increment": "1",
27-
"startWith": "1",
28-
"minValue": "1",
29-
"maxValue": "2147483647",
30-
"cache": "1",
31-
"cycle": false
32-
}
22+
"notNull": true
3323
},
3424
"content": {
3525
"name": "content",
@@ -39,30 +29,30 @@
3929
},
4030
"userId": {
4131
"name": "userId",
42-
"type": "text",
32+
"type": "uuid",
4333
"primaryKey": false,
4434
"notNull": true
4535
},
4636
"roomId": {
4737
"name": "roomId",
48-
"type": "text",
38+
"type": "uuid",
4939
"primaryKey": false,
5040
"notNull": true
5141
},
5242
"createdAt": {
5343
"name": "createdAt",
5444
"type": "timestamp",
5545
"primaryKey": false,
56-
"notNull": true,
46+
"notNull": false,
5747
"default": "now()"
5848
}
5949
},
6050
"indexes": {},
6151
"foreignKeys": {
62-
"Chat_userId_User_id_fk": {
63-
"name": "Chat_userId_User_id_fk",
64-
"tableFrom": "Chat",
65-
"tableTo": "User",
52+
"chat_userId_user_id_fk": {
53+
"name": "chat_userId_user_id_fk",
54+
"tableFrom": "chat",
55+
"tableTo": "user",
6656
"columnsFrom": [
6757
"userId"
6858
],
@@ -72,10 +62,10 @@
7262
"onDelete": "no action",
7363
"onUpdate": "no action"
7464
},
75-
"Chat_roomId_Room_id_fk": {
76-
"name": "Chat_roomId_Room_id_fk",
77-
"tableFrom": "Chat",
78-
"tableTo": "Room",
65+
"chat_roomId_room_id_fk": {
66+
"name": "chat_roomId_room_id_fk",
67+
"tableFrom": "chat",
68+
"tableTo": "room",
7969
"columnsFrom": [
8070
"roomId"
8171
],
@@ -92,8 +82,8 @@
9282
"checkConstraints": {},
9383
"isRLSEnabled": false
9484
},
95-
"public.Draw": {
96-
"name": "Draw",
85+
"public.draw": {
86+
"name": "draw",
9787
"schema": "",
9888
"columns": {
9989
"id": {
@@ -171,23 +161,23 @@
171161
},
172162
"points": {
173163
"name": "points",
174-
"type": "jsonb",
164+
"type": "json",
175165
"primaryKey": false,
176166
"notNull": false
177167
},
178168
"roomId": {
179169
"name": "roomId",
180-
"type": "text",
170+
"type": "uuid",
181171
"primaryKey": false,
182172
"notNull": true
183173
}
184174
},
185175
"indexes": {},
186176
"foreignKeys": {
187-
"Draw_roomId_Room_id_fk": {
188-
"name": "Draw_roomId_Room_id_fk",
189-
"tableFrom": "Draw",
190-
"tableTo": "Room",
177+
"draw_roomId_room_id_fk": {
178+
"name": "draw_roomId_room_id_fk",
179+
"tableFrom": "draw",
180+
"tableTo": "room",
191181
"columnsFrom": [
192182
"roomId"
193183
],
@@ -204,50 +194,50 @@
204194
"checkConstraints": {},
205195
"isRLSEnabled": false
206196
},
207-
"public._participants": {
208-
"name": "_participants",
197+
"public.room_participants": {
198+
"name": "room_participants",
209199
"schema": "",
210200
"columns": {
211-
"A": {
212-
"name": "A",
213-
"type": "text",
201+
"roomId": {
202+
"name": "roomId",
203+
"type": "uuid",
214204
"primaryKey": false,
215205
"notNull": true
216206
},
217-
"B": {
218-
"name": "B",
219-
"type": "text",
207+
"userId": {
208+
"name": "userId",
209+
"type": "uuid",
220210
"primaryKey": false,
221211
"notNull": true
222212
}
223213
},
224214
"indexes": {},
225215
"foreignKeys": {
226-
"_participants_A_Room_id_fk": {
227-
"name": "_participants_A_Room_id_fk",
228-
"tableFrom": "_participants",
229-
"tableTo": "Room",
216+
"room_participants_roomId_room_id_fk": {
217+
"name": "room_participants_roomId_room_id_fk",
218+
"tableFrom": "room_participants",
219+
"tableTo": "room",
230220
"columnsFrom": [
231-
"A"
221+
"roomId"
232222
],
233223
"columnsTo": [
234224
"id"
235225
],
236-
"onDelete": "cascade",
237-
"onUpdate": "cascade"
226+
"onDelete": "no action",
227+
"onUpdate": "no action"
238228
},
239-
"_participants_B_User_id_fk": {
240-
"name": "_participants_B_User_id_fk",
241-
"tableFrom": "_participants",
242-
"tableTo": "User",
229+
"room_participants_userId_user_id_fk": {
230+
"name": "room_participants_userId_user_id_fk",
231+
"tableFrom": "room_participants",
232+
"tableTo": "user",
243233
"columnsFrom": [
244-
"B"
234+
"userId"
245235
],
246236
"columnsTo": [
247237
"id"
248238
],
249-
"onDelete": "cascade",
250-
"onUpdate": "cascade"
239+
"onDelete": "no action",
240+
"onUpdate": "no action"
251241
}
252242
},
253243
"compositePrimaryKeys": {},
@@ -256,15 +246,16 @@
256246
"checkConstraints": {},
257247
"isRLSEnabled": false
258248
},
259-
"public.Room": {
260-
"name": "Room",
249+
"public.room": {
250+
"name": "room",
261251
"schema": "",
262252
"columns": {
263253
"id": {
264254
"name": "id",
265-
"type": "text",
255+
"type": "uuid",
266256
"primaryKey": true,
267-
"notNull": true
257+
"notNull": true,
258+
"default": "gen_random_uuid()"
268259
},
269260
"title": {
270261
"name": "title",
@@ -280,24 +271,24 @@
280271
},
281272
"adminId": {
282273
"name": "adminId",
283-
"type": "text",
274+
"type": "uuid",
284275
"primaryKey": false,
285276
"notNull": true
286277
},
287278
"createdAt": {
288279
"name": "createdAt",
289280
"type": "timestamp",
290281
"primaryKey": false,
291-
"notNull": true,
282+
"notNull": false,
292283
"default": "now()"
293284
}
294285
},
295286
"indexes": {},
296287
"foreignKeys": {
297-
"Room_adminId_User_id_fk": {
298-
"name": "Room_adminId_User_id_fk",
299-
"tableFrom": "Room",
300-
"tableTo": "User",
288+
"room_adminId_user_id_fk": {
289+
"name": "room_adminId_user_id_fk",
290+
"tableFrom": "room",
291+
"tableTo": "user",
301292
"columnsFrom": [
302293
"adminId"
303294
],
@@ -310,8 +301,8 @@
310301
},
311302
"compositePrimaryKeys": {},
312303
"uniqueConstraints": {
313-
"Room_joinCode_unique": {
314-
"name": "Room_joinCode_unique",
304+
"room_joinCode_unique": {
305+
"name": "room_joinCode_unique",
315306
"nullsNotDistinct": false,
316307
"columns": [
317308
"joinCode"
@@ -322,15 +313,16 @@
322313
"checkConstraints": {},
323314
"isRLSEnabled": false
324315
},
325-
"public.User": {
326-
"name": "User",
316+
"public.user": {
317+
"name": "user",
327318
"schema": "",
328319
"columns": {
329320
"id": {
330321
"name": "id",
331-
"type": "text",
322+
"type": "uuid",
332323
"primaryKey": true,
333-
"notNull": true
324+
"notNull": true,
325+
"default": "gen_random_uuid()"
334326
},
335327
"username": {
336328
"name": "username",
@@ -361,8 +353,8 @@
361353
"foreignKeys": {},
362354
"compositePrimaryKeys": {},
363355
"uniqueConstraints": {
364-
"User_username_unique": {
365-
"name": "User_username_unique",
356+
"user_username_unique": {
357+
"name": "user_username_unique",
366358
"nullsNotDistinct": false,
367359
"columns": [
368360
"username"

0 commit comments

Comments
 (0)