Skip to content

Commit 2f2a323

Browse files
authored
Merge branch 'development' into fix/th-183-fix-the-phone-field
2 parents 4f871f6 + 13a9639 commit 2f2a323

File tree

158 files changed

+4306
-325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+4306
-325
lines changed

backend/src/libs/exceptions/database/database-connection.exception.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
type Constructor = {
2-
message: string;
3-
cause?: unknown;
4-
};
1+
import { type Constructor } from '~/libs/types/types.js';
52

63
class DatabaseConnectionError extends Error {
74
public constructor({ message, cause }: Constructor) {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
CREATE TABLE IF NOT EXISTS
2+
"driver_details" (
3+
"id" serial PRIMARY KEY NOT NULL,
4+
"driver_license_number" varchar NOT NULL,
5+
"user_id" integer NOT NULL,
6+
"business_id" integer NOT NULL,
7+
"created_at" timestamp DEFAULT now() NOT NULL,
8+
"updated_at" timestamp DEFAULT now() NOT NULL,
9+
CONSTRAINT "driver_details_driver_license_number_unique" UNIQUE ("driver_license_number")
10+
);
11+
12+
--> statement-breakpoint
13+
DO $$ BEGIN
14+
ALTER TABLE "driver_details" ADD CONSTRAINT "driver_details_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE no action ON UPDATE no action;
15+
EXCEPTION
16+
WHEN duplicate_object THEN null;
17+
END $$;
18+
19+
--> statement-breakpoint
20+
DO $$ BEGIN
21+
ALTER TABLE "driver_details" ADD CONSTRAINT "driver_details_business_id_business_details_id_fk" FOREIGN KEY ("business_id") REFERENCES "business_details"("id") ON DELETE no action ON UPDATE no action;
22+
EXCEPTION
23+
WHEN duplicate_object THEN null;
24+
END $$;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
CREATE TABLE IF NOT EXISTS
2+
"trucks" (
3+
"id" serial PRIMARY KEY NOT NULL,
4+
"created_at" timestamp DEFAULT now() NOT NULL,
5+
"updated_at" timestamp DEFAULT now() NOT NULL,
6+
"manufacturer" varchar NOT NULL,
7+
"capacity" integer NOT NULL,
8+
"price_per_km" real NOT NULL,
9+
"license_plate_number" varchar NOT NULL,
10+
"year" integer NOT NULL,
11+
"tow_type" varchar NOT NULL
12+
);
13+
14+
--> statement-breakpoint
15+
CREATE TABLE IF NOT EXISTS
16+
"users_trucks" (
17+
"user_id" integer NOT NULL,
18+
"truck_id" integer NOT NULL,
19+
CONSTRAINT users_trucks_user_id_truck_id PRIMARY KEY ("user_id", "truck_id")
20+
);
21+
22+
--> statement-breakpoint
23+
CREATE UNIQUE INDEX IF NOT EXISTS "trucks_license_plate_number_idx" ON "trucks" ("license_plate_number");
24+
25+
--> statement-breakpoint
26+
DO $$ BEGIN
27+
ALTER TABLE "users_trucks" ADD CONSTRAINT "users_trucks_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE cascade ON UPDATE no action;
28+
EXCEPTION
29+
WHEN duplicate_object THEN null;
30+
END $$;
31+
32+
--> statement-breakpoint
33+
DO $$ BEGIN
34+
ALTER TABLE "users_trucks" ADD CONSTRAINT "users_trucks_truck_id_trucks_id_fk" FOREIGN KEY ("truck_id") REFERENCES "trucks"("id") ON DELETE cascade ON UPDATE no action;
35+
EXCEPTION
36+
WHEN duplicate_object THEN null;
37+
END $$;
Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
{
2+
"version": "5",
3+
"dialect": "pg",
4+
"id": "bf19a957-5022-41f0-80bc-2557c64ff740",
5+
"prevId": "dd8363c1-1ee4-472f-93b3-cfe9bf6a5348",
6+
"tables": {
7+
"business_details": {
8+
"name": "business_details",
9+
"schema": "",
10+
"columns": {
11+
"id": {
12+
"name": "id",
13+
"type": "serial",
14+
"primaryKey": true,
15+
"notNull": true
16+
},
17+
"company_name": {
18+
"name": "company_name",
19+
"type": "varchar",
20+
"primaryKey": false,
21+
"notNull": true
22+
},
23+
"tax_number": {
24+
"name": "tax_number",
25+
"type": "varchar",
26+
"primaryKey": false,
27+
"notNull": true
28+
},
29+
"owner_id": {
30+
"name": "owner_id",
31+
"type": "integer",
32+
"primaryKey": false,
33+
"notNull": true
34+
},
35+
"created_at": {
36+
"name": "created_at",
37+
"type": "timestamp",
38+
"primaryKey": false,
39+
"notNull": true,
40+
"default": "now()"
41+
},
42+
"updated_at": {
43+
"name": "updated_at",
44+
"type": "timestamp",
45+
"primaryKey": false,
46+
"notNull": true,
47+
"default": "now()"
48+
}
49+
},
50+
"indexes": {},
51+
"foreignKeys": {
52+
"business_details_owner_id_users_id_fk": {
53+
"name": "business_details_owner_id_users_id_fk",
54+
"tableFrom": "business_details",
55+
"tableTo": "users",
56+
"columnsFrom": ["owner_id"],
57+
"columnsTo": ["id"],
58+
"onDelete": "no action",
59+
"onUpdate": "no action"
60+
}
61+
},
62+
"compositePrimaryKeys": {},
63+
"uniqueConstraints": {
64+
"business_details_company_name_unique": {
65+
"name": "business_details_company_name_unique",
66+
"nullsNotDistinct": false,
67+
"columns": ["company_name"]
68+
},
69+
"business_details_tax_number_unique": {
70+
"name": "business_details_tax_number_unique",
71+
"nullsNotDistinct": false,
72+
"columns": ["tax_number"]
73+
}
74+
}
75+
},
76+
"driver_details": {
77+
"name": "driver_details",
78+
"schema": "",
79+
"columns": {
80+
"id": {
81+
"name": "id",
82+
"type": "serial",
83+
"primaryKey": true,
84+
"notNull": true
85+
},
86+
"driver_license_number": {
87+
"name": "driver_license_number",
88+
"type": "varchar",
89+
"primaryKey": false,
90+
"notNull": true
91+
},
92+
"user_id": {
93+
"name": "user_id",
94+
"type": "integer",
95+
"primaryKey": false,
96+
"notNull": true
97+
},
98+
"business_id": {
99+
"name": "business_id",
100+
"type": "integer",
101+
"primaryKey": false,
102+
"notNull": true
103+
},
104+
"created_at": {
105+
"name": "created_at",
106+
"type": "timestamp",
107+
"primaryKey": false,
108+
"notNull": true,
109+
"default": "now()"
110+
},
111+
"updated_at": {
112+
"name": "updated_at",
113+
"type": "timestamp",
114+
"primaryKey": false,
115+
"notNull": true,
116+
"default": "now()"
117+
}
118+
},
119+
"indexes": {},
120+
"foreignKeys": {
121+
"driver_details_user_id_users_id_fk": {
122+
"name": "driver_details_user_id_users_id_fk",
123+
"tableFrom": "driver_details",
124+
"tableTo": "users",
125+
"columnsFrom": ["user_id"],
126+
"columnsTo": ["id"],
127+
"onDelete": "no action",
128+
"onUpdate": "no action"
129+
},
130+
"driver_details_business_id_business_details_id_fk": {
131+
"name": "driver_details_business_id_business_details_id_fk",
132+
"tableFrom": "driver_details",
133+
"tableTo": "business_details",
134+
"columnsFrom": ["business_id"],
135+
"columnsTo": ["id"],
136+
"onDelete": "no action",
137+
"onUpdate": "no action"
138+
}
139+
},
140+
"compositePrimaryKeys": {},
141+
"uniqueConstraints": {
142+
"driver_details_driver_license_number_unique": {
143+
"name": "driver_details_driver_license_number_unique",
144+
"nullsNotDistinct": false,
145+
"columns": ["driver_license_number"]
146+
}
147+
}
148+
},
149+
"groups": {
150+
"name": "groups",
151+
"schema": "",
152+
"columns": {
153+
"id": {
154+
"name": "id",
155+
"type": "serial",
156+
"primaryKey": true,
157+
"notNull": true
158+
},
159+
"name": {
160+
"name": "name",
161+
"type": "varchar",
162+
"primaryKey": false,
163+
"notNull": true
164+
},
165+
"key": {
166+
"name": "key",
167+
"type": "varchar",
168+
"primaryKey": false,
169+
"notNull": true
170+
},
171+
"created_at": {
172+
"name": "created_at",
173+
"type": "timestamp",
174+
"primaryKey": false,
175+
"notNull": true,
176+
"default": "now()"
177+
},
178+
"updated_at": {
179+
"name": "updated_at",
180+
"type": "timestamp",
181+
"primaryKey": false,
182+
"notNull": true,
183+
"default": "now()"
184+
}
185+
},
186+
"indexes": {},
187+
"foreignKeys": {},
188+
"compositePrimaryKeys": {},
189+
"uniqueConstraints": {}
190+
},
191+
"users": {
192+
"name": "users",
193+
"schema": "",
194+
"columns": {
195+
"id": {
196+
"name": "id",
197+
"type": "serial",
198+
"primaryKey": true,
199+
"notNull": true
200+
},
201+
"phone": {
202+
"name": "phone",
203+
"type": "varchar",
204+
"primaryKey": false,
205+
"notNull": true
206+
},
207+
"email": {
208+
"name": "email",
209+
"type": "varchar",
210+
"primaryKey": false,
211+
"notNull": true
212+
},
213+
"first_name": {
214+
"name": "first_name",
215+
"type": "varchar",
216+
"primaryKey": false,
217+
"notNull": true
218+
},
219+
"last_name": {
220+
"name": "last_name",
221+
"type": "varchar",
222+
"primaryKey": false,
223+
"notNull": true
224+
},
225+
"password_hash": {
226+
"name": "password_hash",
227+
"type": "varchar",
228+
"primaryKey": false,
229+
"notNull": true
230+
},
231+
"password_salt": {
232+
"name": "password_salt",
233+
"type": "varchar",
234+
"primaryKey": false,
235+
"notNull": true
236+
},
237+
"group_id": {
238+
"name": "group_id",
239+
"type": "integer",
240+
"primaryKey": false,
241+
"notNull": true
242+
},
243+
"access_token": {
244+
"name": "access_token",
245+
"type": "varchar",
246+
"primaryKey": false,
247+
"notNull": false
248+
},
249+
"created_at": {
250+
"name": "created_at",
251+
"type": "timestamp",
252+
"primaryKey": false,
253+
"notNull": true,
254+
"default": "now()"
255+
},
256+
"updated_at": {
257+
"name": "updated_at",
258+
"type": "timestamp",
259+
"primaryKey": false,
260+
"notNull": true,
261+
"default": "now()"
262+
}
263+
},
264+
"indexes": {
265+
"users_phone_unique_idx": {
266+
"name": "users_phone_unique_idx",
267+
"columns": ["phone"],
268+
"isUnique": true
269+
},
270+
"users_email_unique_idx": {
271+
"name": "users_email_unique_idx",
272+
"columns": ["email"],
273+
"isUnique": true
274+
}
275+
},
276+
"foreignKeys": {
277+
"users_group_id_groups_id_fk": {
278+
"name": "users_group_id_groups_id_fk",
279+
"tableFrom": "users",
280+
"tableTo": "groups",
281+
"columnsFrom": ["group_id"],
282+
"columnsTo": ["id"],
283+
"onDelete": "no action",
284+
"onUpdate": "no action"
285+
}
286+
},
287+
"compositePrimaryKeys": {},
288+
"uniqueConstraints": {}
289+
}
290+
},
291+
"enums": {},
292+
"schemas": {},
293+
"_meta": {
294+
"schemas": {},
295+
"tables": {},
296+
"columns": {}
297+
}
298+
}

0 commit comments

Comments
 (0)