CREATE TABLE IF NOT EXISTS "energy_assessment_scenarios" (
	"id" bigserial PRIMARY KEY NOT NULL,
	"scenario_name" text NOT NULL,
	"energy_assessment_id" bigint NOT NULL
);
--> statement-breakpoint
ALTER TABLE "energy_assessment_documents" ADD COLUMN "scenario_id" bigint;--> statement-breakpoint
DO $$ BEGIN
 ALTER TABLE "energy_assessment_documents" ADD CONSTRAINT "energy_assessment_documents_energy_assessment_id_energy_assessments_id_fk" FOREIGN KEY ("energy_assessment_id") REFERENCES "energy_assessments"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
 ALTER TABLE "energy_assessment_documents" ADD CONSTRAINT "energy_assessment_documents_scenario_id_energy_assessments_id_fk" FOREIGN KEY ("scenario_id") REFERENCES "energy_assessments"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
 ALTER TABLE "energy_assessment_scenarios" ADD CONSTRAINT "energy_assessment_scenarios_energy_assessment_id_energy_assessments_id_fk" FOREIGN KEY ("energy_assessment_id") REFERENCES "energy_assessments"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;
