CREATE TABLE IF NOT EXISTS "non_intrusive_survey" (
	"id" bigserial PRIMARY KEY NOT NULL,
	"uprn" bigint,
	"survey_date" timestamp,
	"surveyor" text
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "non_intrusive_survey_notes" (
	"id" bigserial PRIMARY KEY NOT NULL,
	"survey_id" bigint NOT NULL,
	"title" text,
	"note" text
);
--> statement-breakpoint
ALTER TABLE "recommendation" ADD COLUMN "is_override" boolean DEFAULT false;--> statement-breakpoint
DO $$ BEGIN
 ALTER TABLE "non_intrusive_survey_notes" ADD CONSTRAINT "non_intrusive_survey_notes_survey_id_non_intrusive_survey_id_fk" FOREIGN KEY ("survey_id") REFERENCES "non_intrusive_survey"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;
