Schema Changes
This commit is contained in:
@@ -9,7 +9,7 @@ export const holidays = pgTable("holidays", {
|
|||||||
|
|
||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
|
|
||||||
stateCode: text("state_code").notNull(),
|
state_code: text("state_code").notNull(),
|
||||||
|
|
||||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
|
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -17,18 +17,18 @@ import {sql} from "drizzle-orm";
|
|||||||
export const stafftimeentries = pgTable("staff_time_entries", {
|
export const stafftimeentries = pgTable("staff_time_entries", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
|
|
||||||
tenantId: bigint("tenant_id", { mode: "number" })
|
tenant_id: bigint("tenant_id", { mode: "number" })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => tenants.id),
|
.references(() => tenants.id),
|
||||||
|
|
||||||
userId: uuid("user_id")
|
user_id: uuid("user_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => authUsers.id, { onDelete: "cascade" }),
|
.references(() => authUsers.id, { onDelete: "cascade" }),
|
||||||
|
|
||||||
startedAt: timestamp("started_at", { withTimezone: true }).notNull(),
|
started_at: timestamp("started_at", { withTimezone: true }).notNull(),
|
||||||
stoppedAt: timestamp("stopped_at", { withTimezone: true }),
|
stopped_at: timestamp("stopped_at", { withTimezone: true }),
|
||||||
|
|
||||||
durationMinutes: integer("duration_minutes").generatedAlwaysAs(
|
duration_minutes: integer("duration_minutes").generatedAlwaysAs(
|
||||||
sql`CASE
|
sql`CASE
|
||||||
WHEN stopped_at IS NOT NULL
|
WHEN stopped_at IS NOT NULL
|
||||||
THEN (EXTRACT(epoch FROM (stopped_at - started_at)) / 60)
|
THEN (EXTRACT(epoch FROM (stopped_at - started_at)) / 60)
|
||||||
@@ -40,12 +40,12 @@ export const stafftimeentries = pgTable("staff_time_entries", {
|
|||||||
|
|
||||||
description: text("description"),
|
description: text("description"),
|
||||||
|
|
||||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
|
created_at: timestamp("created_at", { withTimezone: true }).defaultNow(),
|
||||||
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
|
updated_at: timestamp("updated_at", { withTimezone: true }).defaultNow(),
|
||||||
|
|
||||||
archived: boolean("archived").notNull().default(false),
|
archived: boolean("archived").notNull().default(false),
|
||||||
|
|
||||||
updatedBy: uuid("updated_by").references(() => authUsers.id),
|
updated_by: uuid("updated_by").references(() => authUsers.id),
|
||||||
|
|
||||||
source: text("source"),
|
source: text("source"),
|
||||||
|
|
||||||
@@ -53,15 +53,15 @@ export const stafftimeentries = pgTable("staff_time_entries", {
|
|||||||
|
|
||||||
device: uuid("device"),
|
device: uuid("device"),
|
||||||
|
|
||||||
internalNote: text("internal_note"),
|
internal_note: text("internal_note"),
|
||||||
|
|
||||||
vacationReason: text("vacation_reason"),
|
vacation_reason: text("vacation_reason"),
|
||||||
vacationDays: numeric("vacation_days", { precision: 5, scale: 2 }),
|
vacation_days: numeric("vacation_days", { precision: 5, scale: 2 }),
|
||||||
|
|
||||||
approvedBy: uuid("approved_by").references(() => authUsers.id),
|
approved_by: uuid("approved_by").references(() => authUsers.id),
|
||||||
approvedAt: timestamp("approved_at", { withTimezone: true }),
|
approved_at: timestamp("approved_at", { withTimezone: true }),
|
||||||
|
|
||||||
sickReason: text("sick_reason"),
|
sick_reason: text("sick_reason"),
|
||||||
})
|
})
|
||||||
|
|
||||||
export type StaffTimeEntry = typeof stafftimeentries.$inferSelect
|
export type StaffTimeEntry = typeof stafftimeentries.$inferSelect
|
||||||
|
|||||||
@@ -10,17 +10,17 @@ import {
|
|||||||
import { stafftimeentries } from "./staff_time_entries"
|
import { stafftimeentries } from "./staff_time_entries"
|
||||||
import {sql} from "drizzle-orm";
|
import {sql} from "drizzle-orm";
|
||||||
|
|
||||||
export const staffTimeEntryConnects = pgTable("staff_time_entry_connects", {
|
export const stafftimenetryconnects = pgTable("staff_time_entry_connects", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
|
|
||||||
timeEntryId: uuid("time_entry_id")
|
stafftimeentry: uuid("time_entry_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => stafftimeentries.id, { onDelete: "cascade" }),
|
.references(() => stafftimeentries.id, { onDelete: "cascade" }),
|
||||||
|
|
||||||
projectId: bigint("project_id", { mode: "number" }), // referenziert später projects.id
|
project_id: bigint("project_id", { mode: "number" }), // referenziert später projects.id
|
||||||
|
|
||||||
startedAt: timestamp("started_at", { withTimezone: true }).notNull(),
|
started_at: timestamp("started_at", { withTimezone: true }).notNull(),
|
||||||
stoppedAt: timestamp("stopped_at", { withTimezone: true }).notNull(),
|
stopped_at: timestamp("stopped_at", { withTimezone: true }).notNull(),
|
||||||
|
|
||||||
durationMinutes: integer("duration_minutes").generatedAlwaysAs(
|
durationMinutes: integer("duration_minutes").generatedAlwaysAs(
|
||||||
sql`(EXTRACT(epoch FROM (stopped_at - started_at)) / 60)`
|
sql`(EXTRACT(epoch FROM (stopped_at - started_at)) / 60)`
|
||||||
@@ -28,11 +28,11 @@ export const staffTimeEntryConnects = pgTable("staff_time_entry_connects", {
|
|||||||
|
|
||||||
notes: text("notes"),
|
notes: text("notes"),
|
||||||
|
|
||||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
|
created_at: timestamp("created_at", { withTimezone: true }).defaultNow(),
|
||||||
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
|
updated_at: timestamp("updated_at", { withTimezone: true }).defaultNow(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export type StaffTimeEntryConnect =
|
export type StaffTimeEntryConnect =
|
||||||
typeof staffTimeEntryConnects.$inferSelect
|
typeof stafftimenetryconnects.$inferSelect
|
||||||
export type NewStaffTimeEntryConnect =
|
export type NewStaffTimeEntryConnect =
|
||||||
typeof staffTimeEntryConnects.$inferInsert
|
typeof stafftimenetryconnects.$inferInsert
|
||||||
|
|||||||
Reference in New Issue
Block a user