27 lines
982 B
TypeScript
27 lines
982 B
TypeScript
import { bigint, pgTable, primaryKey, timestamp, uuid } from "drizzle-orm/pg-core"
|
|
|
|
import { authUsers } from "./auth_users"
|
|
import { communicationRooms } from "./communication_rooms"
|
|
|
|
export const communicationRoomReads = pgTable(
|
|
"communication_room_reads",
|
|
{
|
|
roomId: uuid("room_id")
|
|
.notNull()
|
|
.references(() => communicationRooms.id, { onDelete: "cascade" }),
|
|
userId: uuid("user_id")
|
|
.notNull()
|
|
.references(() => authUsers.id, { onDelete: "cascade" }),
|
|
lastReadMessageId: bigint("last_read_message_id", { mode: "number" }),
|
|
readAt: timestamp("read_at", { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow(),
|
|
},
|
|
(table) => ({
|
|
pk: primaryKey({ columns: [table.roomId, table.userId] }),
|
|
})
|
|
)
|
|
|
|
export type CommunicationRoomRead = typeof communicationRoomReads.$inferSelect
|
|
export type NewCommunicationRoomRead = typeof communicationRoomReads.$inferInsert
|