import { index, pgTable, primaryKey, timestamp, uuid } from "drizzle-orm/pg-core" import { authUsers } from "./auth_users" import { communicationRooms } from "./communication_rooms" export const communicationRoomMembers = pgTable( "communication_room_members", { roomId: uuid("room_id") .notNull() .references(() => communicationRooms.id, { onDelete: "cascade" }), userId: uuid("user_id") .notNull() .references(() => authUsers.id, { onDelete: "cascade" }), joinedAt: timestamp("joined_at", { withTimezone: true }) .notNull() .defaultNow(), }, (table) => ({ pk: primaryKey({ columns: [table.roomId, table.userId] }), userIdx: index("communication_room_members_user_idx").on(table.userId), }) ) export type CommunicationRoomMember = typeof communicationRoomMembers.$inferSelect export type NewCommunicationRoomMember = typeof communicationRoomMembers.$inferInsert