Skip to content

Commit 6bfe29b

Browse files
authored
th-87: Implement Truck creation flow (#116)
* th-65: + trucks and usersTrucks tables schema * th-65: + database migrations for trucks and users-trucks schema * th-65: + truck entity * th-65: * usersTrucks schema * th-65: + migration trucks and users_trucks * th-65: + trucks repository * th-65: * formatting * th-65: * users_trucks table * th-65: * delete migration * th-65: * migrations trucks and users_trucks * th-65: + year of manufacture truck * th-65: * separate truck entity into FE and BE * th-65: + database exception * th-65: * refactored truck repository * th-87: + truck year enum * th-87: + tow truck type * th-87: + truck add request dto * th-87: + truck manufacturer * th-87: + fields creating truck * th-87: + default field values creating truck * th-87: + form creating truck * th-87: + dropdown component * th-87: + attributes * th-87: + extend formfield * th-87: + validation truck creating schema * th-87: + trucks package * th-87: + truck enums * th-87: + truck types * th-87: * trucks exports * th-87: + trucks-api * th-87: * truck add request dto * th-87: * truck entity * th-87: * validation scema * th-87: + truck service * th-87: * truck repository * th-87: + truck controller * th-87: * field default constants * th-87: - truck table schema * th-87: * database truck migration * th-87: * method names * th-87: * add truck form * th-87: + controller implementation * th-87: * truck entity naming * th-87: * truck repository * th-87: * truck entity * th-87: * truck repository * th-87: * truck service * th-87: + swagger doc controller * th-87: - default price * th-87: - truck component * th-87: * truck entity * th-87: * erDiagram * th-87: * truck controller * th-87: * optional name, control, errors * th-87: * validation schema * th-87: - database exception wrapper * th-87: * truck entity type * th-87: * database trucks table * th-87: * truck repository * th-87: * truck service * th-87: * http code for delete, validation schema * th-87: * truck field enums * th-87: * field condition * th-87: * switch render field * th-87: + get truck entity helper * th-87: * remove storage * th-87: * truck entity import * th-87: * truck add form model * th-87: + swagger template example * th-87: * truck validation * th-87: * truck repository naming * th-87: * step * th-87: * generic select option * th-87: * trucks api * th-87: * imports * th-87: * truck validation * th-87: * helpers * th-87: * form component * th-87: + folders for constants * th-87: * validation messages * th-87: * regexp license plate number * th-87: * naming, consts and validation
1 parent 58c9857 commit 6bfe29b

File tree

67 files changed

+2194
-31
lines changed

Some content is hidden

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

67 files changed

+2194
-31
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: 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 $$;

0 commit comments

Comments
 (0)