import { integer, real, sqliteTable, text } from "drizzle-orm/sqlite-core"; import { circuits } from "./circuits.js"; import { projectDevices } from "./project-devices.js"; import { rooms } from "./rooms.js"; export const circuitDeviceRows = sqliteTable("circuit_device_rows", { id: text("id").primaryKey(), circuitId: text("circuit_id") .notNull() .references(() => circuits.id, { onDelete: "cascade" }), linkedProjectDeviceId: text("linked_project_device_id").references(() => projectDevices.id, { onDelete: "set null", }), legacyConsumerId: text("legacy_consumer_id"), sortOrder: integer("sort_order").notNull().default(0), name: text("name").notNull(), displayName: text("display_name").notNull(), phaseType: text("phase_type"), connectionKind: text("connection_kind"), costGroup: text("cost_group"), category: text("category"), level: text("level"), roomId: text("room_id").references(() => rooms.id, { onDelete: "set null", }), roomNumberSnapshot: text("room_number_snapshot"), roomNameSnapshot: text("room_name_snapshot"), quantity: integer("quantity").notNull(), powerPerUnit: real("power_per_unit").notNull(), simultaneityFactor: real("simultaneity_factor").notNull(), cosPhi: real("cos_phi"), remark: text("remark"), overriddenFields: text("overridden_fields"), });