From f0d53d4e86009f9480805f68afe178c4d7d620df Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Tue, 26 May 2026 10:25:42 +0000 Subject: [PATCH] some comments to understand the sql more --- src/app/db/migrations/0205_wonderful_pixie.sql | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/db/migrations/0205_wonderful_pixie.sql b/src/app/db/migrations/0205_wonderful_pixie.sql index 282e8bd..1cddf64 100644 --- a/src/app/db/migrations/0205_wonderful_pixie.sql +++ b/src/app/db/migrations/0205_wonderful_pixie.sql @@ -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; \ No newline at end of file