CREATE TYPE "public"."roof_type" AS ENUM('Flat, insulated', 'Flat, insulated (assumed)', 'Flat, limited insulation', 'Flat, limited insulation (assumed)', 'Flat, no insulation', 'Flat, no insulation (assumed)', 'Pitched, insulated', 'Pitched, insulated (assumed)', 'Pitched, insulated at rafters', 'Pitched, limited insulation', 'Pitched, limited insulation (assumed)', 'Pitched, no insulation', 'Pitched, no insulation (assumed)', 'Pitched, Unknown loft insulation', 'Pitched, 0 mm loft insulation', 'Pitched, 12 mm loft insulation', 'Pitched, 25 mm loft insulation', 'Pitched, 50 mm loft insulation', 'Pitched, 75 mm loft insulation', 'Pitched, 100 mm loft insulation', 'Pitched, 125 mm loft insulation', 'Pitched, 150 mm loft insulation', 'Pitched, 175 mm loft insulation', 'Pitched, 200 mm loft insulation', 'Pitched, 225 mm loft insulation', 'Pitched, 250 mm loft insulation', 'Pitched, 270 mm loft insulation', 'Pitched, 300 mm loft insulation', 'Pitched, 350 mm loft insulation', 'Pitched, 400 mm loft insulation', 'Pitched, 400+ mm loft insulation', 'Roof room(s), insulated', 'Roof room(s), insulated (assumed)', 'Roof room(s), limited insulation', 'Roof room(s), limited insulation (assumed)', 'Roof room(s), no insulation', 'Roof room(s), no insulation (assumed)', 'Roof room(s), ceiling insulated', 'Roof room(s), thatched', 'Roof room(s), thatched with additional insulation', 'Thatched', 'Thatched, with additional insulation', '(another dwelling above)', '(same dwelling above)', '(other premises above)', '(another premises above)', 'Another Premises Above', 'Unknown');--> statement-breakpoint
CREATE TABLE "landlord_roof_type_overrides" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"portfolio_id" bigint NOT NULL,
	"description" text NOT NULL,
	"value" "roof_type" NOT NULL,
	"source" "override_source" NOT NULL,
	"created_at" timestamp with time zone DEFAULT now() NOT NULL,
	"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
	CONSTRAINT "landlord_roof_type_overrides_portfolio_description_unique" UNIQUE("portfolio_id","description")
);
--> statement-breakpoint
ALTER TABLE "landlord_roof_type_overrides" ADD CONSTRAINT "landlord_roof_type_overrides_portfolio_id_portfolio_id_fk" FOREIGN KEY ("portfolio_id") REFERENCES "public"."portfolio"("id") ON DELETE cascade ON UPDATE no action;