Schema Changes

This commit is contained in:
2025-12-08 12:15:27 +01:00
parent 428a002e9f
commit c1120d1878
3 changed files with 24 additions and 24 deletions

View File

@@ -17,18 +17,18 @@ import {sql} from "drizzle-orm";
export const stafftimeentries = pgTable("staff_time_entries", {
id: uuid("id").primaryKey().defaultRandom(),
tenantId: bigint("tenant_id", { mode: "number" })
tenant_id: bigint("tenant_id", { mode: "number" })
.notNull()
.references(() => tenants.id),
userId: uuid("user_id")
user_id: uuid("user_id")
.notNull()
.references(() => authUsers.id, { onDelete: "cascade" }),
startedAt: timestamp("started_at", { withTimezone: true }).notNull(),
stoppedAt: timestamp("stopped_at", { withTimezone: true }),
started_at: timestamp("started_at", { withTimezone: true }).notNull(),
stopped_at: timestamp("stopped_at", { withTimezone: true }),
durationMinutes: integer("duration_minutes").generatedAlwaysAs(
duration_minutes: integer("duration_minutes").generatedAlwaysAs(
sql`CASE
WHEN stopped_at IS NOT NULL
THEN (EXTRACT(epoch FROM (stopped_at - started_at)) / 60)
@@ -40,12 +40,12 @@ export const stafftimeentries = pgTable("staff_time_entries", {
description: text("description"),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
created_at: timestamp("created_at", { withTimezone: true }).defaultNow(),
updated_at: timestamp("updated_at", { withTimezone: true }).defaultNow(),
archived: boolean("archived").notNull().default(false),
updatedBy: uuid("updated_by").references(() => authUsers.id),
updated_by: uuid("updated_by").references(() => authUsers.id),
source: text("source"),
@@ -53,15 +53,15 @@ export const stafftimeentries = pgTable("staff_time_entries", {
device: uuid("device"),
internalNote: text("internal_note"),
internal_note: text("internal_note"),
vacationReason: text("vacation_reason"),
vacationDays: numeric("vacation_days", { precision: 5, scale: 2 }),
vacation_reason: text("vacation_reason"),
vacation_days: numeric("vacation_days", { precision: 5, scale: 2 }),
approvedBy: uuid("approved_by").references(() => authUsers.id),
approvedAt: timestamp("approved_at", { withTimezone: true }),
approved_by: uuid("approved_by").references(() => authUsers.id),
approved_at: timestamp("approved_at", { withTimezone: true }),
sickReason: text("sick_reason"),
sick_reason: text("sick_reason"),
})
export type StaffTimeEntry = typeof stafftimeentries.$inferSelect