Merge pull request #278 from Hestia-Homes/feautre/additional_walltypes

built type
This commit is contained in:
Jun-te Kim 2026-05-26 16:05:43 +01:00 committed by GitHub
commit a08188404c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9822 additions and 1 deletions

View file

@ -0,0 +1,13 @@
CREATE TYPE "public"."built_form_type" AS ENUM('Detached', 'Semi-Detached', 'Mid-Terrace', 'End-Terrace', 'Enclosed Mid-Terrace', 'Enclosed End-Terrace', 'Not Recorded', 'Unknown');--> statement-breakpoint
CREATE TABLE "landlord_built_form_type_overrides" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"portfolio_id" bigint NOT NULL,
"description" text NOT NULL,
"value" "built_form_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_built_form_type_overrides_portfolio_description_unique" UNIQUE("portfolio_id","description")
);
--> statement-breakpoint
ALTER TABLE "landlord_built_form_type_overrides" ADD CONSTRAINT "landlord_built_form_type_overrides_portfolio_id_portfolio_id_fk" FOREIGN KEY ("portfolio_id") REFERENCES "public"."portfolio"("id") ON DELETE cascade ON UPDATE no action;

File diff suppressed because it is too large Load diff

View file

@ -1450,6 +1450,13 @@
"when": 1779805963297,
"tag": "0206_tense_raza",
"breakpoints": true
},
{
"idx": 207,
"version": "7",
"when": 1779807828419,
"tag": "0207_flat_white_queen",
"breakpoints": true
}
]
}

View file

@ -10,7 +10,7 @@ import {
import { portfolio } from "./portfolio";
// Enum string values mirror /workspaces/home/github/Model/domain/landlord_description_overrides/*.py
// exactly (PropertyType.value, WallType.value). Keep in sync — see
// exactly (PropertyType.value, WallType.value, BuiltFormType.value). Keep in sync — see
// docs/adr/0002-landlord-override-vocabulary.md.
export const PropertyTypeValues: [string, ...string[]] = [
"House",
@ -70,6 +70,17 @@ export const WallTypeValues: [string, ...string[]] = [
"Unknown",
];
export const BuiltFormTypeValues: [string, ...string[]] = [
"Detached",
"Semi-Detached",
"Mid-Terrace",
"End-Terrace",
"Enclosed Mid-Terrace",
"Enclosed End-Terrace",
"Not Recorded",
"Unknown",
];
export const OverrideSourceValues: [string, ...string[]] = [
"classifier",
"user",
@ -77,6 +88,7 @@ export const OverrideSourceValues: [string, ...string[]] = [
export const propertyTypeEnum = pgEnum("property_type", PropertyTypeValues);
export const wallTypeEnum = pgEnum("wall_type", WallTypeValues);
export const builtFormTypeEnum = pgEnum("built_form_type", BuiltFormTypeValues);
export const overrideSourceEnum = pgEnum(
"override_source",
OverrideSourceValues,
@ -131,3 +143,28 @@ export const landlordWallTypeOverrides = pgTable(
).on(table.portfolioId, table.description),
}),
);
export const landlordBuiltFormTypeOverrides = pgTable(
"landlord_built_form_type_overrides",
{
id: uuid("id").defaultRandom().primaryKey(),
portfolioId: bigint("portfolio_id", { mode: "bigint" })
.notNull()
.references(() => portfolio.id, { onDelete: "cascade" }),
description: text("description").notNull(),
value: builtFormTypeEnum("value").notNull(),
source: overrideSourceEnum("source").notNull(),
createdAt: timestamp("created_at", { withTimezone: true })
.notNull()
.defaultNow(),
updatedAt: timestamp("updated_at", { withTimezone: true })
.notNull()
.defaultNow()
.$onUpdate(() => new Date()),
},
(table) => ({
portfolioDescriptionUnique: unique(
"landlord_built_form_type_overrides_portfolio_description_unique",
).on(table.portfolioId, table.description),
}),
);