39 lines
1.2 KiB
TypeScript
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 staffTimeEntryConnects = pgTable("staff_time_entry_connects", {
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
|
|
timeEntryId: uuid("time_entry_id")
|
|
.notNull()
|
|
.references(() => stafftimeentries.id, { onDelete: "cascade" }),
|
|
|
|
projectId: bigint("project_id", { mode: "number" }), // referenziert später projects.id
|
|
|
|
startedAt: timestamp("started_at", { withTimezone: true }).notNull(),
|
|
stoppedAt: timestamp("stopped_at", { withTimezone: true }).notNull(),
|
|
|
|
durationMinutes: integer("duration_minutes").generatedAlwaysAs(
|
|
sql`(EXTRACT(epoch FROM (stopped_at - started_at)) / 60)`
|
|
),
|
|
|
|
notes: text("notes"),
|
|
|
|
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
|
|
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
|
|
})
|
|
|
|
export type StaffTimeEntryConnect =
|
|
typeof staffTimeEntryConnects.$inferSelect
|
|
export type NewStaffTimeEntryConnect =
|
|
typeof staffTimeEntryConnects.$inferInsert
|