CREATE TABLE "bidding-projects" (
	"id" serial PRIMARY KEY NOT NULL,
	"pspid" char(24) PRIMARY KEY NOT NULL,
	"proj_nm" varchar(90),
	"sector" char(1),
	"proj_msrm" numeric(3, 0),
	"kunnr" char(10),
	"kunnr_nm" varchar(30),
	"cls_1" char(10),
	"cls1_nm" varchar(30),
	"ptype" char(3),
	"ptype_nm" varchar(40),
	"pmodel_cd" char(10),
	"pmodel_nm" varchar(40),
	"pmodel_sz" varchar(20),
	"pmodel_uom" char(5),
	"txt04" char(4),
	"txt30" varchar(30),
	"estm_pm" varchar(30),
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "project_series" (
	"pspid" char(24) NOT NULL,
	"sers_no" numeric(3, 0) NOT NULL,
	"kl_qtr" char(10),
	"dock_no" char(3),
	"dock_nm" varchar(40),
	"proj_no" char(24),
	"post1" varchar(40)
);
--> statement-breakpoint
ALTER TABLE "rfqs" ADD COLUMN "bid_project_id" integer;--> statement-breakpoint
ALTER TABLE "project_series" ADD CONSTRAINT "project_series_pspid_bidding-projects_pspid_fk" FOREIGN KEY ("pspid") REFERENCES "public"."bidding-projects"("pspid") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "proeject_sersNo_unique" ON "project_series" USING btree ("pspid","sers_no");--> statement-breakpoint
ALTER TABLE "rfqs" ADD CONSTRAINT "rfqs_bid_project_id_bidding-projects_id_fk" FOREIGN KEY ("bid_project_id") REFERENCES "public"."bidding-projects"("id") ON DELETE set null ON UPDATE no action;