feat(notifications): add notifications + notificationPreferences tables

This commit is contained in:
Gabriel Brown
2026-07-11 15:42:14 -04:00
parent 0347d58f71
commit 05eabcb0fa
2 changed files with 103 additions and 0 deletions
+31
View File
@@ -835,6 +835,37 @@ const applicationTables = {
})
.index('by_thread', ['threadId'])
.index('by_owner', ['ownerId']),
notifications: defineTable({
userId: v.id('users'),
kind: v.union(
v.literal('maintenance_thread'),
v.literal('agent_turn_finished'),
v.literal('agent_needs_input'),
v.literal('sync_failed'),
v.literal('connection_needs_reauth'),
),
title: v.string(),
body: v.string(),
link: v.optional(v.string()),
spoonId: v.optional(v.id('spoons')),
threadId: v.optional(v.id('threads')),
readAt: v.optional(v.number()),
emailedAt: v.optional(v.number()),
createdAt: v.number(),
})
.index('by_user', ['userId'])
.index('by_user_unread', ['userId', 'readAt'])
.index('by_user_created', ['userId', 'createdAt']),
notificationPreferences: defineTable({
userId: v.id('users'),
emailEnabled: v.optional(v.boolean()),
emailMaintenance: v.optional(v.boolean()),
emailAgentTurnFinished: v.optional(v.boolean()),
emailAgentNeedsInput: v.optional(v.boolean()),
emailSyncFailed: v.optional(v.boolean()),
emailConnectionReauth: v.optional(v.boolean()),
updatedAt: v.number(),
}).index('by_user', ['userId']),
ignoredUpstreamChanges: defineTable({
spoonId: v.id('spoons'),
ownerId: v.id('users'),