Introduced New DB
This commit is contained in:
38
db/schema/staff_time_entry_connects.ts
Normal file
38
db/schema/staff_time_entry_connects.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
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
|
||||
Reference in New Issue
Block a user