Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 39x 39x 39x 2x 2x 2x 2x | import { createId } from '@paralleldrive/cuid2'
import { integer, sqliteTable, text, uniqueIndex } from 'drizzle-orm/sqlite-core'
import { arcadeRooms } from './arcade-rooms'
/**
* Room invitations sent by hosts to users
* Used to invite users back after unbanning or to invite new users
*/
export const roomInvitations = sqliteTable(
'room_invitations',
{
id: text('id')
.primaryKey()
.$defaultFn(() => createId()),
roomId: text('room_id')
.notNull()
.references(() => arcadeRooms.id, { onDelete: 'cascade' }),
// Invited user
userId: text('user_id').notNull(),
userName: text('user_name', { length: 50 }).notNull(), // Name at time of invitation
// Who invited them
invitedBy: text('invited_by').notNull(), // Host user ID
invitedByName: text('invited_by_name', { length: 50 }).notNull(),
// Invitation status
status: text('status', {
enum: ['pending', 'accepted', 'declined', 'expired'],
})
.notNull()
.default('pending'),
// Type of invitation
invitationType: text('invitation_type', {
enum: ['manual', 'auto-unban', 'auto-create'],
})
.notNull()
.default('manual'),
// Optional message
message: text('message', { length: 500 }),
// Timestamps
createdAt: integer('created_at', { mode: 'timestamp' })
.notNull()
.$defaultFn(() => new Date()),
respondedAt: integer('responded_at', { mode: 'timestamp' }),
expiresAt: integer('expires_at', { mode: 'timestamp' }), // Optional expiration
},
(table) => ({
// One pending invitation per user per room
userRoomIdx: uniqueIndex('idx_room_invitations_user_room').on(table.userId, table.roomId),
})
)
export type RoomInvitation = typeof roomInvitations.$inferSelect
export type NewRoomInvitation = typeof roomInvitations.$inferInsert
|