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 | 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 39x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x | import { createId } from '@paralleldrive/cuid2'
import { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
import { users } from './users'
import { players } from './players'
export const practiceNotificationSubscriptions = sqliteTable(
'practice_notification_subscriptions',
{
id: text('id')
.primaryKey()
.$defaultFn(() => createId()),
userId: text('user_id').references(() => users.id, { onDelete: 'cascade' }),
playerId: text('player_id')
.notNull()
.references(() => players.id, { onDelete: 'cascade' }),
email: text('email'),
pushSubscription: text('push_subscription', { mode: 'json' }).$type<WebPushSubscriptionJson>(),
channels: text('channels', { mode: 'json' }).$type<SubscriptionChannels>().notNull(),
status: text('status', { enum: ['active', 'paused', 'expired'] })
.notNull()
.default('active'),
label: text('label'),
createdAt: integer('created_at', { mode: 'timestamp' })
.notNull()
.$defaultFn(() => new Date()),
expiresAt: integer('expires_at', { mode: 'timestamp' }),
lastNotifiedAt: integer('last_notified_at', { mode: 'timestamp' }),
},
(table) => ({
playerIdx: index('idx_practice_notif_subs_player').on(table.playerId),
userIdx: index('idx_practice_notif_subs_user').on(table.userId),
statusIdx: index('idx_practice_notif_subs_status').on(table.status),
})
)
export interface WebPushSubscriptionJson {
endpoint: string
keys: { p256dh: string; auth: string }
}
export interface SubscriptionChannels {
webPush?: boolean
inApp?: boolean
email?: boolean
}
export type PracticeNotificationSubscription = typeof practiceNotificationSubscriptions.$inferSelect
export type NewPracticeNotificationSubscription =
typeof practiceNotificationSubscriptions.$inferInsert
|