Add optional room areas

This commit is contained in:
Julian Appel 2026-09-27 20:00:03 +02:00
parent a6500e2b26
commit dce31ee143
26 changed files with 3669 additions and 78 deletions

View file

@ -0,0 +1 @@
ALTER TABLE `rooms` ADD `area_m2` real;

File diff suppressed because it is too large Load diff

View file

@ -78,6 +78,13 @@
"when": 1790438092269,
"tag": "0010_estimate_balances",
"breakpoints": true
},
{
"idx": 11,
"version": "6",
"when": 1790531351492,
"tag": "0011_glossy_norman_osborn",
"breakpoints": true
}
]
}

View file

@ -28,6 +28,7 @@ import {
projectRoomInsertCommandType,
projectRoomUpdateCommandType,
upgradeProjectFloorCommand,
upgradeProjectRoomCommand,
type ProjectBuildingSnapshot,
type ProjectFloorSnapshot,
type ProjectLocationStructureProjectCommand,
@ -106,23 +107,29 @@ export class ProjectLocationStructureProjectCommandRepository
const current = upgradeProjectFloorCommand(command);
return this.updateFloor(database, projectId, current.payload.expected, current.payload.target);
}
case projectRoomInsertCommandType:
case projectRoomInsertCommandType: {
assertProjectRoomInsertProjectCommand(command);
const current = upgradeProjectRoomCommand(command);
return this.insertRoom(
database,
projectId,
command.payload.room
current.payload.room
);
case projectRoomDeleteCommandType:
}
case projectRoomDeleteCommandType: {
assertProjectRoomDeleteProjectCommand(command);
const current = upgradeProjectRoomCommand(command);
return this.deleteRoom(
database,
projectId,
command.payload.room
current.payload.room
);
case projectRoomUpdateCommandType:
}
case projectRoomUpdateCommandType: {
assertProjectRoomUpdateProjectCommand(command);
return this.updateRoom(database, projectId, command.payload.expected, command.payload.target);
const current = upgradeProjectRoomCommand(command);
return this.updateRoom(database, projectId, current.payload.expected, current.payload.target);
}
}
}
@ -393,6 +400,7 @@ export class ProjectLocationStructureProjectCommandRepository
floorId: target.floorId,
roomNumber: target.roomNumber,
roomName: target.roomName,
areaM2: target.areaM2,
})
.where(and(eq(rooms.id, expected.id), eq(rooms.projectId, projectId)))
.run();
@ -474,6 +482,15 @@ function toCurrentCommandVersion(
case projectFloorUpdateCommandType:
assertProjectFloorUpdateProjectCommand(command);
return upgradeProjectFloorCommand(command);
case projectRoomInsertCommandType:
assertProjectRoomInsertProjectCommand(command);
return upgradeProjectRoomCommand(command);
case projectRoomDeleteCommandType:
assertProjectRoomDeleteProjectCommand(command);
return upgradeProjectRoomCommand(command);
case projectRoomUpdateCommandType:
assertProjectRoomUpdateProjectCommand(command);
return upgradeProjectRoomCommand(command);
default:
return command;
}

View file

@ -1,4 +1,4 @@
import { sqliteTable, text } from "drizzle-orm/sqlite-core";
import { real, sqliteTable, text } from "drizzle-orm/sqlite-core";
import { floors } from "./floors.js";
import { projects } from "./projects.js";
@ -10,4 +10,6 @@ export const rooms = sqliteTable("rooms", {
floorId: text("floor_id").references(() => floors.id, { onDelete: "set null" }),
roomNumber: text("room_number").notNull(),
roomName: text("room_name").notNull(),
/** Optional net room area from the Revit room parameter "Fläche". */
areaM2: real("area_m2"),
});