mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
Merge pull request #309 from Hestia-Homes/feature/magicplan-ventilation-tables
New tables for magicplan ventilation and move opening type to window ventilation table
This commit is contained in:
commit
974a5e5ef5
11 changed files with 32804 additions and 7 deletions
21
src/app/db/migrations/0226_massive_guardian.sql
Normal file
21
src/app/db/migrations/0226_massive_guardian.sql
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CREATE TABLE "magic_plan_door_ventilation" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"magic_plan_door_id" bigint NOT NULL,
|
||||
"undercut_mm" real,
|
||||
CONSTRAINT "magic_plan_door_ventilation_magic_plan_door_id_unique" UNIQUE("magic_plan_door_id")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "magic_plan_window_ventilation" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"magic_plan_window_id" bigint NOT NULL,
|
||||
"opening_type" text,
|
||||
"num_openings" integer,
|
||||
"pct_openable" integer,
|
||||
"trickle_vent_area_mm2" integer,
|
||||
"num_trickle_vents" integer,
|
||||
CONSTRAINT "magic_plan_window_ventilation_magic_plan_window_id_unique" UNIQUE("magic_plan_window_id")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "magic_plan_door" ADD COLUMN "height_mm" real;--> statement-breakpoint
|
||||
ALTER TABLE "magic_plan_door_ventilation" ADD CONSTRAINT "magic_plan_door_ventilation_magic_plan_door_id_magic_plan_door_id_fk" FOREIGN KEY ("magic_plan_door_id") REFERENCES "public"."magic_plan_door"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "magic_plan_window_ventilation" ADD CONSTRAINT "magic_plan_window_ventilation_magic_plan_window_id_magic_plan_window_id_fk" FOREIGN KEY ("magic_plan_window_id") REFERENCES "public"."magic_plan_window"("id") ON DELETE cascade ON UPDATE no action;
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
-- Backfill opening_type into magic_plan_window_ventilation from magic_plan_window.
|
||||
-- Only rows with a non-null opening_type are backfilled; no ventilation row is
|
||||
-- created for windows that never had one. The unique constraint on
|
||||
-- magic_plan_window_id prevents duplicate rows if this runs more than once.
|
||||
|
||||
INSERT INTO magic_plan_window_ventilation (magic_plan_window_id, opening_type)
|
||||
SELECT id, opening_type
|
||||
FROM magic_plan_window
|
||||
WHERE opening_type IS NOT NULL
|
||||
ON CONFLICT (magic_plan_window_id) DO NOTHING;
|
||||
1
src/app/db/migrations/0228_deep_betty_ross.sql
Normal file
1
src/app/db/migrations/0228_deep_betty_ross.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE "magic_plan_window" DROP COLUMN "opening_type";
|
||||
10906
src/app/db/migrations/meta/0226_snapshot.json
Normal file
10906
src/app/db/migrations/meta/0226_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
10906
src/app/db/migrations/meta/0227_snapshot.json
Normal file
10906
src/app/db/migrations/meta/0227_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
10900
src/app/db/migrations/meta/0228_snapshot.json
Normal file
10900
src/app/db/migrations/meta/0228_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1576,6 +1576,27 @@
|
|||
"when": 1780654800000,
|
||||
"tag": "0225_recommendation_material_id_backfill",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 226,
|
||||
"version": "7",
|
||||
"when": 1780910378978,
|
||||
"tag": "0226_massive_guardian",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 227,
|
||||
"version": "7",
|
||||
"when": 1780910400000,
|
||||
"tag": "0227_magic_plan_window_ventilation_backfill",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 228,
|
||||
"version": "7",
|
||||
"when": 1780910657380,
|
||||
"tag": "0228_deep_betty_ross",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ export const magicPlanDoor = pgTable(
|
|||
.notNull()
|
||||
.references(() => magicPlanRoom.id),
|
||||
widthMm: real("width_mm"),
|
||||
heightMm: real("height_mm"),
|
||||
type: text("type"),
|
||||
},
|
||||
);
|
||||
14
src/app/db/schema/magic_plan/door_ventilation.ts
Normal file
14
src/app/db/schema/magic_plan/door_ventilation.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { pgTable, bigserial, bigint, real } from "drizzle-orm/pg-core";
|
||||
import { magicPlanDoor } from "./door";
|
||||
|
||||
export const magicPlanDoorVentilation = pgTable(
|
||||
"magic_plan_door_ventilation",
|
||||
{
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
doorId: bigint("magic_plan_door_id", { mode: "bigint" })
|
||||
.notNull()
|
||||
.unique()
|
||||
.references(() => magicPlanDoor.id, { onDelete: "cascade" }),
|
||||
undercutMm: real("undercut_mm"),
|
||||
},
|
||||
);
|
||||
|
|
@ -1,16 +1,15 @@
|
|||
import { pgTable, bigserial, bigint, text, real } from "drizzle-orm/pg-core";
|
||||
import { pgTable, bigserial, bigint, real } from "drizzle-orm/pg-core";
|
||||
import { magicPlanRoom } from "./room";
|
||||
|
||||
export const magicPlanWindow = pgTable(
|
||||
"magic_plan_window",
|
||||
{
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
roomId: bigint("magic_plan_room_id", { mode: "bigint" })
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
roomId: bigint("magic_plan_room_id", { mode: "bigint" })
|
||||
.notNull()
|
||||
.references(() => magicPlanRoom.id),
|
||||
widthM: real("width_m"),
|
||||
heightM: real("height_m"),
|
||||
areaM2: real("area_m2"),
|
||||
openingType: text("opening_type"),
|
||||
widthM: real("width_m"),
|
||||
heightM: real("height_m"),
|
||||
areaM2: real("area_m2"),
|
||||
},
|
||||
);
|
||||
18
src/app/db/schema/magic_plan/window_ventilation.ts
Normal file
18
src/app/db/schema/magic_plan/window_ventilation.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { pgTable, bigserial, bigint, text, integer } from "drizzle-orm/pg-core";
|
||||
import { magicPlanWindow } from "./window";
|
||||
|
||||
export const magicPlanWindowVentilation = pgTable(
|
||||
"magic_plan_window_ventilation",
|
||||
{
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
windowId: bigint("magic_plan_window_id", { mode: "bigint" })
|
||||
.notNull()
|
||||
.unique()
|
||||
.references(() => magicPlanWindow.id, { onDelete: "cascade" }),
|
||||
openingType: text("opening_type"),
|
||||
numOpenings: integer("num_openings"),
|
||||
pctOpenable: integer("pct_openable"),
|
||||
trickleVentAreaMm2: integer("trickle_vent_area_mm2"),
|
||||
numTrickleVents: integer("num_trickle_vents"),
|
||||
},
|
||||
);
|
||||
Loading…
Add table
Reference in a new issue