1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
CREATE TABLE "project_gtc_files" (
"id" serial PRIMARY KEY NOT NULL,
"project_id" integer NOT NULL,
"file_name" varchar(255) NOT NULL,
"file_path" varchar(1024) NOT NULL,
"original_file_name" varchar(255) NOT NULL,
"file_size" integer,
"mime_type" varchar(100),
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "project_gtc_files" ADD CONSTRAINT "project_gtc_files_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
CREATE VIEW "public"."project_gtc_view" AS (select "projects"."id" as "id", "projects"."code" as "code", "projects"."name" as "name", "projects"."type" as "type", "projects"."created_at" as "project_created_at", "projects"."updated_at" as "project_updated_at", "project_gtc_files"."id" as "gtc_file_id", "project_gtc_files"."file_name" as "fileName", "project_gtc_files"."file_path" as "filePath", "project_gtc_files"."original_file_name" as "originalFileName", "project_gtc_files"."file_size" as "fileSize", "project_gtc_files"."mime_type" as "mimeType", "project_gtc_files"."created_at" as "gtcCreatedAt", "project_gtc_files"."updated_at" as "gtcUpdatedAt" from "projects" left join "project_gtc_files" on "projects"."id" = "project_gtc_files"."project_id");
|