Serial and Other

This commit is contained in:
2026-01-01 15:33:48 +01:00
parent 97f66f808a
commit a3df87caee
9 changed files with 910 additions and 7 deletions

View File

@@ -17,6 +17,7 @@ import { letterheads } from "./letterheads"
import { projects } from "./projects"
import { plants } from "./plants"
import { authUsers } from "./auth_users"
import {serialExecutions} from "./serialexecutions";
export const createddocuments = pgTable("createddocuments", {
id: bigint("id", { mode: "number" })
@@ -115,6 +116,8 @@ export const createddocuments = pgTable("createddocuments", {
contract: bigint("contract", { mode: "number" }).references(
() => contracts.id
),
serialexecution: uuid("serialexecution").references(() => serialExecutions.id)
})
export type CreatedDocument = typeof createddocuments.$inferSelect

View File

@@ -68,4 +68,6 @@ export * from "./units"
export * from "./user_credentials"
export * from "./vehicles"
export * from "./vendors"
export * from "./staff_time_events"
export * from "./staff_time_events"
export * from "./serialtypes"
export * from "./serialexecutions"

View File

@@ -0,0 +1,21 @@
import {
pgTable,
bigint,
timestamp,
text,
jsonb,
boolean,
uuid,
} from "drizzle-orm/pg-core"
import {tenants} from "./tenants";
export const serialExecutions = pgTable("serial_executions", {
id: uuid("id").primaryKey().defaultRandom(),
tenant: bigint("tenant", { mode: "number" })
.notNull()
.references(() => tenants.id), executionDate: timestamp("execution_date").notNull(),
status: text("status").default("draft"), // 'draft', 'completed'
createdBy: text("created_by"), // oder UUID, je nach Auth-System
createdAt: timestamp("created_at").defaultNow(),
summary: text("summary"), // z.B. "25 Rechnungen erstellt"
});

40
db/schema/serialtypes.ts Normal file
View File

@@ -0,0 +1,40 @@
import {
pgTable,
bigint,
timestamp,
text,
jsonb,
boolean,
uuid,
} from "drizzle-orm/pg-core"
import { tenants } from "./tenants"
import { authUsers } from "./auth_users"
export const serialtypes = pgTable("serialtypes", {
id: bigint("id", { mode: "number" })
.primaryKey()
.generatedByDefaultAsIdentity(),
createdAt: timestamp("created_at", { withTimezone: true })
.notNull()
.defaultNow(),
name: text("name").notNull(),
intervall: text("intervall"),
icon: text("icon"),
tenant: bigint("tenant", { mode: "number" })
.notNull()
.references(() => tenants.id),
archived: boolean("archived").notNull().default(false),
updatedAt: timestamp("updated_at", { withTimezone: true }),
updatedBy: uuid("updated_by").references(() => authUsers.id),
})
export type SerialType = typeof serialtypes.$inferSelect
export type NewSerialType = typeof serialtypes.$inferInsert