CREATE SCHEMA "ecc";
--> statement-breakpoint
CREATE TABLE "tech_sales_contact_possible_items" (
	"id" serial PRIMARY KEY NOT NULL,
	"contact_id" integer NOT NULL,
	"vendor_possible_item_id" integer NOT NULL,
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "tech_sales_vendor_quotation_contacts" (
	"id" serial PRIMARY KEY NOT NULL,
	"quotation_id" integer NOT NULL,
	"contact_id" integer NOT NULL,
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "ecc"."PR_INFORMATION_T_BID_HEADER" (
	"id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "ecc"."PR_INFORMATION_T_BID_HEADER_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
	"ANFNR" varchar(10) NOT NULL,
	"EKGRP" varchar(10),
	"EKORG" varchar(10),
	"WERKS" varchar(10),
	"ZBSART" varchar(10) NOT NULL,
	"ZRFQ_TRS_DT" varchar(10),
	"ZRFQ_TRS_TM" varchar(10),
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "ecc"."PR_INFORMATION_T_BID_ITEM" (
	"id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "ecc"."PR_INFORMATION_T_BID_ITEM_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
	"ANFNR" varchar(10) NOT NULL,
	"ANFPS" varchar(10) NOT NULL,
	"AUFNR" varchar(12),
	"BANFN" varchar(10) NOT NULL,
	"BANPO" varchar(10) NOT NULL,
	"BPRME" varchar(10),
	"BRGEW" numeric(15, 3),
	"DISMM" varchar(10),
	"EBELP" varchar(10),
	"GEWEI" varchar(10),
	"KNTTP" varchar(10),
	"KOSTL" varchar(10),
	"LFDAT" varchar(10),
	"MATKL" varchar(10),
	"MATNR" varchar(18),
	"MEINS" varchar(10),
	"MENGE" numeric(15, 3),
	"PEINH" integer,
	"PERNR" varchar(20),
	"POSID" varchar(24),
	"PREIS" numeric(15, 2),
	"PSPID" varchar(24),
	"SAKTO" varchar(10),
	"TXZ01" varchar(40),
	"WAERS1" varchar(10),
	"WAERS2" varchar(10),
	"ZCON_NO_PO" varchar(15),
	"ZREQ_FN" varchar(10),
	"ZREQ_PO" varchar(10),
	"ZRSLT_AMT" numeric(17, 2),
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "tech_vendor_contacts" RENAME COLUMN "country" TO "contact_country";--> statement-breakpoint
ALTER TABLE "tech_sales_rfq_comment_attachments" ADD COLUMN "original_file_name" varchar(255) NOT NULL;--> statement-breakpoint
ALTER TABLE "tech_sales_contact_possible_items" ADD CONSTRAINT "tech_sales_contact_possible_items_contact_id_tech_vendor_contacts_id_fk" FOREIGN KEY ("contact_id") REFERENCES "public"."tech_vendor_contacts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tech_sales_contact_possible_items" ADD CONSTRAINT "tech_sales_contact_possible_items_vendor_possible_item_id_tech_vendor_possible_items_id_fk" FOREIGN KEY ("vendor_possible_item_id") REFERENCES "public"."tech_vendor_possible_items"("id") ON DELETE cascade ON UPDATE no action;