CREATE TYPE "public"."main_heating_system" AS ENUM('Gas boiler, combi', 'Gas boiler, regular', 'Gas CPSU', 'Electric storage heaters, fan', 'Direct-acting electric', 'Unknown');--> statement-breakpoint
CREATE TYPE "public"."water_heating" AS ENUM('From main system, mains gas', 'From main system, electricity', 'Electric immersion, electricity', 'Unknown');--> statement-breakpoint
ALTER TYPE "public"."override_component" ADD VALUE 'water_heating';--> statement-breakpoint
ALTER TYPE "public"."override_component" ADD VALUE 'main_heating_system';--> statement-breakpoint
CREATE TABLE "landlord_main_heating_system_overrides" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"portfolio_id" bigint NOT NULL,
	"description" text NOT NULL,
	"value" "main_heating_system" 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_main_heating_system_portfolio_description_unique" UNIQUE("portfolio_id","description")
);
--> statement-breakpoint
CREATE TABLE "landlord_water_heating_overrides" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"portfolio_id" bigint NOT NULL,
	"description" text NOT NULL,
	"value" "water_heating" 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_water_heating_overrides_portfolio_description_unique" UNIQUE("portfolio_id","description")
);
--> statement-breakpoint
ALTER TABLE "landlord_main_heating_system_overrides" ADD CONSTRAINT "landlord_main_heating_system_overrides_portfolio_fk" FOREIGN KEY ("portfolio_id") REFERENCES "public"."portfolio"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "landlord_water_heating_overrides" ADD CONSTRAINT "landlord_water_heating_overrides_portfolio_id_portfolio_id_fk" FOREIGN KEY ("portfolio_id") REFERENCES "public"."portfolio"("id") ON DELETE cascade ON UPDATE no action;