forked from jappel/leistungsbilanz-ts
first commit
This commit is contained in:
commit
c3e98af5b6
36 changed files with 4779 additions and 0 deletions
23
src/db/schema/consumers.ts
Normal file
23
src/db/schema/consumers.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { integer, real, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
||||
import { distributionBoards } from "./distribution-boards.js";
|
||||
import { projects } from "./projects.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",
|
||||
}),
|
||||
name: text("name").notNull(),
|
||||
category: text("category"),
|
||||
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"),
|
||||
});
|
||||
|
||||
11
src/db/schema/distribution-boards.ts
Normal file
11
src/db/schema/distribution-boards.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { sqliteTable, text } from "drizzle-orm/sqlite-core";
|
||||
import { projects } from "./projects.js";
|
||||
|
||||
export const distributionBoards = sqliteTable("distribution_boards", {
|
||||
id: text("id").primaryKey(),
|
||||
projectId: text("project_id")
|
||||
.notNull()
|
||||
.references(() => projects.id, { onDelete: "cascade" }),
|
||||
name: text("name").notNull(),
|
||||
});
|
||||
|
||||
7
src/db/schema/projects.ts
Normal file
7
src/db/schema/projects.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { sqliteTable, text } from "drizzle-orm/sqlite-core";
|
||||
|
||||
export const projects = sqliteTable("projects", {
|
||||
id: text("id").primaryKey(),
|
||||
name: text("name").notNull(),
|
||||
});
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue