summaryrefslogtreecommitdiff
path: root/db/migrations_backup/0082_serious_revanche.sql
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrations_backup/0082_serious_revanche.sql')
-rw-r--r--db/migrations_backup/0082_serious_revanche.sql40
1 files changed, 0 insertions, 40 deletions
diff --git a/db/migrations_backup/0082_serious_revanche.sql b/db/migrations_backup/0082_serious_revanche.sql
deleted file mode 100644
index c48e582b..00000000
--- a/db/migrations_backup/0082_serious_revanche.sql
+++ /dev/null
@@ -1,40 +0,0 @@
-CREATE TABLE "cbe_attachments" (
- "id" serial PRIMARY KEY NOT NULL,
- "cbe_id" integer,
- "file_name" varchar(255) NOT NULL,
- "file_path" varchar(1024) NOT NULL,
- "created_at" timestamp DEFAULT now() NOT NULL
-);
---> statement-breakpoint
-CREATE TABLE "cbe_comments" (
- "id" serial PRIMARY KEY NOT NULL,
- "cbe_id" integer,
- "commented_by" integer,
- "comment_text" text NOT NULL,
- "created_at" timestamp DEFAULT now() NOT NULL
-);
---> statement-breakpoint
-CREATE TABLE "cbe_evaluations" (
- "id" serial PRIMARY KEY NOT NULL,
- "rfq_id" integer NOT NULL,
- "vendor_id" integer NOT NULL,
- "evaluated_by" integer,
- "evaluated_at" timestamp DEFAULT now() NOT NULL,
- "result" varchar(50),
- "total_cost" numeric(18, 2),
- "currency" varchar(10) DEFAULT 'USD',
- "payment_terms" varchar(255),
- "incoterms" varchar(50),
- "delivery_schedule" text,
- "notes" text,
- "created_at" timestamp DEFAULT now() NOT NULL,
- "updated_at" timestamp DEFAULT now() NOT NULL
-);
---> statement-breakpoint
-ALTER TABLE "cbe_attachments" ADD CONSTRAINT "cbe_attachments_cbe_id_cbe_evaluations_id_fk" FOREIGN KEY ("cbe_id") REFERENCES "public"."cbe_evaluations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
-ALTER TABLE "cbe_comments" ADD CONSTRAINT "cbe_comments_cbe_id_cbe_evaluations_id_fk" FOREIGN KEY ("cbe_id") REFERENCES "public"."cbe_evaluations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
-ALTER TABLE "cbe_comments" ADD CONSTRAINT "cbe_comments_commented_by_users_id_fk" FOREIGN KEY ("commented_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
-ALTER TABLE "cbe_evaluations" ADD CONSTRAINT "cbe_evaluations_rfq_id_rfqs_id_fk" FOREIGN KEY ("rfq_id") REFERENCES "public"."rfqs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
-ALTER TABLE "cbe_evaluations" ADD CONSTRAINT "cbe_evaluations_vendor_id_vendors_id_fk" FOREIGN KEY ("vendor_id") REFERENCES "public"."vendors"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
-ALTER TABLE "cbe_evaluations" ADD CONSTRAINT "cbe_evaluations_evaluated_by_users_id_fk" FOREIGN KEY ("evaluated_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
-CREATE VIEW "public"."cbe_view" AS (select "cbe_evaluations"."id" as "cbe_id", "cbe_evaluations"."rfq_id" as "rfq_id", "cbe_evaluations"."vendor_id" as "vendor_id", "cbe_evaluations"."total_cost" as "total_cost", "cbe_evaluations"."currency" as "currency", "cbe_evaluations"."payment_terms" as "payment_terms", "cbe_evaluations"."incoterms" as "incoterms", "cbe_evaluations"."result" as "result", "cbe_evaluations"."notes" as "notes", "cbe_evaluations"."evaluated_by" as "evaluated_by", "cbe_evaluations"."evaluated_at" as "evaluated_at", "rfqs"."rfq_code" as "rfq_code", "rfqs"."description" as "rfq_description", "vendors"."vendor_name" as "vendor_name", "vendors"."vendor_code" as "vendor_code", "projects"."id" as "project_id", "projects"."code" as "project_code", "projects"."name" as "project_name", "users"."name" as "evaluator_name", "users"."email" as "evaluator_email" from "cbe_evaluations" inner join "rfqs" on "cbe_evaluations"."rfq_id" = "rfqs"."id" inner join "vendors" on "cbe_evaluations"."vendor_id" = "vendors"."id" left join "projects" on "rfqs"."project_id" = "projects"."id" left join "users" on "cbe_evaluations"."evaluated_by" = "users"."id"); \ No newline at end of file