CREATE TABLE "vendor_project_pqs" (
	"id" serial PRIMARY KEY NOT NULL,
	"vendor_id" integer NOT NULL,
	"project_id" integer NOT NULL,
	"status" varchar(20) DEFAULT 'REQUESTED' NOT NULL,
	"submitted_at" timestamp,
	"approved_at" timestamp,
	"rejected_at" timestamp,
	"reject_reason" text,
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "vendor_pq_criteria_answers" DROP CONSTRAINT "vendor_pq_criteria_answers_vendor_id_vendors_id_fk";
--> statement-breakpoint
ALTER TABLE "vendor_pq_criteria_answers" DROP CONSTRAINT "vendor_pq_criteria_answers_criteria_id_pq_criterias_id_fk";
--> statement-breakpoint
ALTER TABLE "vendor_pq_criteria_answers" ADD COLUMN "project_id" integer;--> statement-breakpoint
ALTER TABLE "vendor_project_pqs" ADD CONSTRAINT "vendor_project_pqs_vendor_id_vendors_id_fk" FOREIGN KEY ("vendor_id") REFERENCES "public"."vendors"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "vendor_project_pqs" ADD CONSTRAINT "vendor_project_pqs_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "vendor_pq_criteria_answers" ADD CONSTRAINT "vendor_pq_criteria_answers_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "vendor_pq_criteria_answers" ADD CONSTRAINT "vendor_pq_criteria_answers_vendor_id_vendors_id_fk" FOREIGN KEY ("vendor_id") REFERENCES "public"."vendors"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "vendor_pq_criteria_answers" ADD CONSTRAINT "vendor_pq_criteria_answers_criteria_id_pq_criterias_id_fk" FOREIGN KEY ("criteria_id") REFERENCES "public"."pq_criterias"("id") ON DELETE cascade ON UPDATE cascade;