KI-AGENT: Anrufhistorie für Telefonie ergänzen
This commit is contained in:
@@ -75,6 +75,7 @@ export * from "./statementallocations"
|
||||
export * from "./tasks"
|
||||
export * from "./teams"
|
||||
export * from "./taxtypes"
|
||||
export * from "./telephony_calls"
|
||||
export * from "./tenants"
|
||||
export * from "./texttemplates"
|
||||
export * from "./units"
|
||||
|
||||
56
backend/db/schema/telephony_calls.ts
Normal file
56
backend/db/schema/telephony_calls.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import {
|
||||
pgTable,
|
||||
uuid,
|
||||
bigint,
|
||||
text,
|
||||
timestamp,
|
||||
integer,
|
||||
index,
|
||||
} from "drizzle-orm/pg-core"
|
||||
|
||||
import { tenants } from "./tenants"
|
||||
import { authUsers } from "./auth_users"
|
||||
|
||||
export const telephonyCalls = pgTable(
|
||||
"telephony_calls",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
|
||||
tenantId: bigint("tenant_id", { mode: "number" })
|
||||
.notNull()
|
||||
.references(() => tenants.id, { onDelete: "cascade" }),
|
||||
|
||||
direction: text("direction").notNull(),
|
||||
status: text("status").notNull().default("ringing"),
|
||||
|
||||
localExtension: text("local_extension"),
|
||||
remoteNumber: text("remote_number"),
|
||||
remoteDisplayName: text("remote_display_name"),
|
||||
sipCallId: text("sip_call_id"),
|
||||
|
||||
startedAt: timestamp("started_at", { withTimezone: true })
|
||||
.notNull()
|
||||
.defaultNow(),
|
||||
answeredAt: timestamp("answered_at", { withTimezone: true }),
|
||||
endedAt: timestamp("ended_at", { withTimezone: true }),
|
||||
durationSeconds: integer("duration_seconds"),
|
||||
|
||||
createdAt: timestamp("created_at", { withTimezone: true })
|
||||
.notNull()
|
||||
.defaultNow(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }),
|
||||
createdBy: uuid("created_by").references(() => authUsers.id),
|
||||
updatedBy: uuid("updated_by").references(() => authUsers.id),
|
||||
},
|
||||
(table) => ({
|
||||
tenantStartedIdx: index("telephony_calls_tenant_started_idx")
|
||||
.on(table.tenantId, table.startedAt),
|
||||
createdByIdx: index("telephony_calls_created_by_idx")
|
||||
.on(table.tenantId, table.createdBy),
|
||||
sipCallIdx: index("telephony_calls_sip_call_idx")
|
||||
.on(table.tenantId, table.sipCallId),
|
||||
})
|
||||
)
|
||||
|
||||
export type TelephonyCall = typeof telephonyCalls.$inferSelect
|
||||
export type NewTelephonyCall = typeof telephonyCalls.$inferInsert
|
||||
Reference in New Issue
Block a user