35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
import { integer, real, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
|
|
import { circuitLists } from "./circuit-lists.js";
|
|
import { circuitSections } from "./circuit-sections.js";
|
|
|
|
export const circuits = sqliteTable(
|
|
"circuits",
|
|
{
|
|
id: text("id").primaryKey(),
|
|
circuitListId: text("circuit_list_id")
|
|
.notNull()
|
|
.references(() => circuitLists.id, { onDelete: "cascade" }),
|
|
sectionId: text("section_id")
|
|
.notNull()
|
|
.references(() => circuitSections.id, { onDelete: "cascade" }),
|
|
equipmentIdentifier: text("equipment_identifier").notNull(),
|
|
displayName: text("display_name"),
|
|
sortOrder: integer("sort_order").notNull().default(0),
|
|
protectionType: text("protection_type"),
|
|
protectionRatedCurrent: real("protection_rated_current"),
|
|
protectionCharacteristic: text("protection_characteristic"),
|
|
cableType: text("cable_type"),
|
|
cableCrossSection: text("cable_cross_section"),
|
|
cableLength: real("cable_length"),
|
|
rcdAssignment: text("rcd_assignment"),
|
|
terminalDesignation: text("terminal_designation"),
|
|
voltage: real("voltage"),
|
|
controlRequirement: text("control_requirement"),
|
|
status: text("status"),
|
|
isReserve: integer("is_reserve").notNull().default(0),
|
|
remark: text("remark"),
|
|
},
|
|
(table) => [unique("circuits_list_equipment_identifier_unique").on(table.circuitListId, table.equipmentIdentifier)]
|
|
);
|
|
|