import {
    pgTable,
    uuid,
    timestamp,
    bigint,
    text,
} from "drizzle-orm/pg-core"

import { tenants } from "./tenants"
import { authProfiles } from "./auth_profiles"
import { stafftimeentries } from "./staff_time_entries"

export const staffZeitstromTimestamps = pgTable("staff_zeitstromtimestamps", {
    id: uuid("id").primaryKey().defaultRandom(),

    createdAt: timestamp("created_at", { withTimezone: true })
        .notNull()
        .defaultNow(),

    tenant: bigint("tenant", { mode: "number" })
        .notNull()
        .references(() => tenants.id),

    profile: uuid("profile")
        .notNull()
        .references(() => authProfiles.id),

    key: text("key").notNull(),

    intent: text("intent").notNull(),

    time: timestamp("time", { withTimezone: true }).notNull(),

    staffTimeEntry: uuid("staff_time_entry").references(
        () => stafftimeentries.id
    ),

    internalNote: text("internal_note"),
})

export type StaffZeitstromTimestamp =
    typeof staffZeitstromTimestamps.$inferSelect
export type NewStaffZeitstromTimestamp =
    typeof staffZeitstromTimestamps.$inferInsert
