43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import { integer, real, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
|
import { circuitLists } from "./circuit-lists.js";
|
|
import { distributionBoards } from "./distribution-boards.js";
|
|
import { projects } from "./projects.js";
|
|
import { rooms } from "./rooms.js";
|
|
|
|
export const consumers = sqliteTable("consumers", {
|
|
id: text("id").primaryKey(),
|
|
projectId: text("project_id")
|
|
.notNull()
|
|
.references(() => projects.id, { onDelete: "cascade" }),
|
|
distributionBoardId: text("distribution_board_id").references(() => distributionBoards.id, {
|
|
onDelete: "set null",
|
|
}),
|
|
circuitListId: text("circuit_list_id").references(() => circuitLists.id, {
|
|
onDelete: "set null",
|
|
}),
|
|
roomId: text("room_id").references(() => rooms.id, {
|
|
onDelete: "set null",
|
|
}),
|
|
circuitNumber: text("circuit_number"),
|
|
description: text("description"),
|
|
name: text("name").notNull(),
|
|
category: text("category"),
|
|
deviceType: text("device_type"),
|
|
phaseType: text("phase_type"),
|
|
tradeOrCostGroup: text("trade_or_cost_group"),
|
|
group: text("group_name"),
|
|
protectionType: text("protection_type"),
|
|
protectionRatedCurrent: real("protection_rated_current"),
|
|
protectionCharacteristic: text("protection_characteristic"),
|
|
cableType: text("cable_type"),
|
|
cableCrossSection: text("cable_cross_section"),
|
|
comment: text("comment"),
|
|
quantity: integer("quantity").notNull(),
|
|
installedPowerPerUnitKw: real("installed_power_per_unit_kw").notNull(),
|
|
demandFactor: real("demand_factor").notNull(),
|
|
voltageV: real("voltage_v"),
|
|
phaseCount: integer("phase_count"),
|
|
powerFactor: real("power_factor"),
|
|
note: text("note"),
|
|
});
|