Files
FEDEO/backend/db/schema/contacts.ts
2026-01-06 12:07:43 +01:00

67 lines
1.6 KiB
TypeScript

import {
pgTable,
bigint,
text,
timestamp,
boolean,
jsonb,
date,
uuid,
} from "drizzle-orm/pg-core"
import { customers } from "./customers"
import { tenants } from "./tenants"
import { authUsers } from "./auth_users"
export const contacts = pgTable(
"contacts",
{
id: bigint("id", { mode: "number" })
.primaryKey()
.generatedByDefaultAsIdentity(),
createdAt: timestamp("created_at", { withTimezone: true })
.notNull()
.defaultNow(),
firstName: text("firstName"),
lastName: text("lastName"),
email: text("email"),
customer: bigint("customer", { mode: "number" }).references(
() => customers.id
),
tenant: bigint("tenant", { mode: "number" }).notNull(),
phoneMobile: text("phoneMobile"),
phoneHome: text("phoneHome"),
heroId: text("heroId"),
role: text("role"),
fullName: text("fullName"),
salutation: text("salutation"),
vendor: bigint("vendor", { mode: "number" }), // vendors folgt separat
active: boolean("active").notNull().default(true),
birthday: date("birthday"),
notes: text("notes"),
profiles: jsonb("profiles").notNull().default([]),
archived: boolean("archived").notNull().default(false),
title: text("title"),
updatedAt: timestamp("updated_at", { withTimezone: true }),
updatedBy: uuid("updated_by").references(() => authUsers.id),
}
)
export type Contact = typeof contacts.$inferSelect
export type NewContact = typeof contacts.$inferInsert