some comments to understand the sql more

This commit is contained in:
Jun-te Kim 2026-05-26 10:25:42 +00:00
parent b8be604ab3
commit f0d53d4e86

View file

@ -1,6 +1,10 @@
-- ENUM definition
CREATE TYPE "public"."override_source" AS ENUM('classifier', 'user');--> statement-breakpoint
CREATE TYPE "public"."property_type" AS ENUM('House', 'Bungalow', 'Flat', 'Maisonette', 'Park home', 'Unknown');--> statement-breakpoint
CREATE TYPE "public"."wall_type" AS ENUM('Cavity', 'Solid Brick', 'Timber frame', 'Sandstone', 'Unknown');--> statement-breakpoint
-- Lanlord Property Type overides
CREATE TABLE "landlord_property_type_overrides" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"portfolio_id" bigint NOT NULL,
@ -11,7 +15,8 @@ CREATE TABLE "landlord_property_type_overrides" (
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "landlord_property_type_overrides_portfolio_description_unique" UNIQUE("portfolio_id","description")
);
--> statement-breakpoint
-- Lanlodrd Wall type overrides
CREATE TABLE "landlord_wall_type_overrides" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"portfolio_id" bigint NOT NULL,
@ -22,6 +27,7 @@ CREATE TABLE "landlord_wall_type_overrides" (
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "landlord_wall_type_overrides_portfolio_description_unique" UNIQUE("portfolio_id","description")
);
--> statement-breakpoint
-- Add portfolio_id, so we know which portfolio its from
ALTER TABLE "landlord_property_type_overrides" ADD CONSTRAINT "landlord_property_type_overrides_portfolio_id_portfolio_id_fk" FOREIGN KEY ("portfolio_id") REFERENCES "public"."portfolio"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "landlord_wall_type_overrides" ADD CONSTRAINT "landlord_wall_type_overrides_portfolio_id_portfolio_id_fk" FOREIGN KEY ("portfolio_id") REFERENCES "public"."portfolio"("id") ON DELETE cascade ON UPDATE no action;