Files
FEDEO/backend/db/schema/staff_time_entry_connects.ts
2026-01-06 12:07:43 +01:00

39 lines
1.2 KiB
TypeScript

import {
pgTable,
uuid,
bigint,
timestamp,
integer,
text,
} from "drizzle-orm/pg-core"
import { stafftimeentries } from "./staff_time_entries"
import {sql} from "drizzle-orm";
export const stafftimenetryconnects = pgTable("staff_time_entry_connects", {
id: uuid("id").primaryKey().defaultRandom(),
stafftimeentry: uuid("time_entry_id")
.notNull()
.references(() => stafftimeentries.id, { onDelete: "cascade" }),
project_id: bigint("project_id", { mode: "number" }), // referenziert später projects.id
started_at: timestamp("started_at", { withTimezone: true }).notNull(),
stopped_at: timestamp("stopped_at", { withTimezone: true }).notNull(),
durationMinutes: integer("duration_minutes").generatedAlwaysAs(
sql`(EXTRACT(epoch FROM (stopped_at - started_at)) / 60)`
),
notes: text("notes"),
created_at: timestamp("created_at", { withTimezone: true }).defaultNow(),
updated_at: timestamp("updated_at", { withTimezone: true }).defaultNow(),
})
export type StaffTimeEntryConnect =
typeof stafftimenetryconnects.$inferSelect
export type NewStaffTimeEntryConnect =
typeof stafftimenetryconnects.$inferInsert