Add component persistence foundation

This commit is contained in:
Julian Appel 2026-07-30 19:15:00 +02:00
parent a88c4b2086
commit e7607c90c4
15 changed files with 3146 additions and 12 deletions

View file

@ -0,0 +1,26 @@
import { sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
import { circuitLists } from "./circuit-lists.js";
export const circuitListEquipmentIdentifiers = sqliteTable(
"circuit_list_equipment_identifiers",
{
ownerType: text("owner_type")
.$type<"circuit" | "distribution_board_component">()
.notNull(),
ownerId: text("owner_id").notNull(),
circuitListId: text("circuit_list_id")
.notNull()
.references(() => circuitLists.id, { onDelete: "cascade" }),
equipmentIdentifier: text("equipment_identifier").notNull(),
},
(table) => [
unique("circuit_list_equipment_identifiers_owner_unique").on(
table.ownerType,
table.ownerId
),
unique("circuit_list_equipment_identifiers_list_identifier_unique").on(
table.circuitListId,
table.equipmentIdentifier
),
]
);