Skip to content
Source
Sign inSign up
TanStack/schemas
Open History to see the last commit

schema.ts

666 lines22.4 KB

1import { relations, sql } from 'drizzle-orm'
2import {
3 sqliteTable,
4 text,
5 integer,
6 index,
7 check,
8 primaryKey,
9} from 'drizzle-orm/sqlite-core'
10import type { AnySQLiteColumn } from 'drizzle-orm/sqlite-core'
11​
12import type { CapabilityMap } from '#/lib/capabilities.ts'
13​
14export const user = sqliteTable('user', {
15 id: text('id').primaryKey(),
16 name: text('name').notNull(),
17 email: text('email').notNull().unique(),
18 emailVerified: integer('email_verified', { mode: 'boolean' })
19 .default(false)
20 .notNull(),
21 image: text('image'),
22 createdAt: integer('created_at', { mode: 'timestamp_ms' }).notNull(),
23 updatedAt: integer('updated_at', { mode: 'timestamp_ms' })
24 .$onUpdate(() => new Date())
25 .notNull(),
26})
27​
28export const session = sqliteTable(
29 'session',
30 {
31 id: text('id').primaryKey(),
32 expiresAt: integer('expires_at', { mode: 'timestamp_ms' }).notNull(),
33 token: text('token').notNull().unique(),
34 createdAt: integer('created_at', { mode: 'timestamp_ms' }).notNull(),
35 updatedAt: integer('updated_at', { mode: 'timestamp_ms' })
36 .$onUpdate(() => new Date())
37 .notNull(),
38 ipAddress: text('ip_address'),
39 userAgent: text('user_agent'),
40 userId: text('user_id')
41 .notNull()
42 .references(() => user.id, { onDelete: 'cascade' }),
43 },
44 (table) => [index('session_userId_idx').on(table.userId)],
46​
47export const account = sqliteTable(
48 'account',
49 {
50 id: text('id').primaryKey(),
51 accountId: text('account_id').notNull(),
52 providerId: text('provider_id').notNull(),
53 userId: text('user_id')
54 .notNull()
55 .references(() => user.id, { onDelete: 'cascade' }),
56 accessToken: text('access_token'),
57 refreshToken: text('refresh_token'),
58 idToken: text('id_token'),
59 accessTokenExpiresAt: integer('access_token_expires_at', {
60 mode: 'timestamp_ms',
61 }),
62 refreshTokenExpiresAt: integer('refresh_token_expires_at', {
63 mode: 'timestamp_ms',
64 }),
65 scope: text('scope'),
66 password: text('password'),
67 createdAt: integer('created_at', { mode: 'timestamp_ms' }).notNull(),
68 updatedAt: integer('updated_at', { mode: 'timestamp_ms' })
69 .$onUpdate(() => new Date())
70 .notNull(),
71 },
72 (table) => [index('account_userId_idx').on(table.userId)],
74​
75export const verification = sqliteTable(
76 'verification',
77 {
78 id: text('id').primaryKey(),
79 identifier: text('identifier').notNull(),
80 value: text('value').notNull(),
81 expiresAt: integer('expires_at', { mode: 'timestamp_ms' }).notNull(),
82 createdAt: integer('created_at', { mode: 'timestamp_ms' }).notNull(),
83 updatedAt: integer('updated_at', { mode: 'timestamp_ms' })
84 .$onUpdate(() => new Date())
85 .notNull(),
86 },
87 (table) => [index('verification_identifier_idx').on(table.identifier)],
89​
90export const agentHost = sqliteTable(
91 'agent_host',
92 {
93 id: text('id').primaryKey(),
94 name: text('name'),
95 userId: text('user_id').references(() => user.id, { onDelete: 'cascade' }),
96 defaultCapabilities: text('default_capabilities'),
97 publicKey: text('public_key'),
98 kid: text('kid'),
99 jwksUrl: text('jwks_url'),
100 enrollmentTokenHash: text('enrollment_token_hash'),
101 enrollmentTokenExpiresAt: integer('enrollment_token_expires_at', {
102 mode: 'timestamp_ms',
103 }),
104 status: text('status').default('active').notNull(),
105 activatedAt: integer('activated_at', { mode: 'timestamp_ms' }),
106 expiresAt: integer('expires_at', { mode: 'timestamp_ms' }),
107 lastUsedAt: integer('last_used_at', { mode: 'timestamp_ms' }),
108 createdAt: integer('created_at', { mode: 'timestamp_ms' }).notNull(),
109 updatedAt: integer('updated_at', { mode: 'timestamp_ms' }).notNull(),
110 },
111 (table) => [
112 index('agentHost_userId_idx').on(table.userId),
113 index('agentHost_kid_idx').on(table.kid),
114 index('agentHost_enrollmentTokenHash_idx').on(table.enrollmentTokenHash),
115 index('agentHost_status_idx').on(table.status),
116 ],
118​
119export const agent = sqliteTable(
120 'agent',
121 {
122 id: text('id').primaryKey(),
123 name: text('name').notNull(),
124 userId: text('user_id').references(() => user.id, { onDelete: 'cascade' }),
125 hostId: text('host_id')
126 .notNull()
127 .references(() => agentHost.id, { onDelete: 'cascade' }),
128 status: text('status').default('active').notNull(),
129 mode: text('mode').default('delegated').notNull(),
130 publicKey: text('public_key').notNull(),
131 kid: text('kid'),
132 jwksUrl: text('jwks_url'),
133 lastUsedAt: integer('last_used_at', { mode: 'timestamp_ms' }),
134 activatedAt: integer('activated_at', { mode: 'timestamp_ms' }),
135 expiresAt: integer('expires_at', { mode: 'timestamp_ms' }),
136 metadata: text('metadata'),
137 createdAt: integer('created_at', { mode: 'timestamp_ms' }).notNull(),
138 updatedAt: integer('updated_at', { mode: 'timestamp_ms' }).notNull(),
139 },
140 (table) => [
141 index('agent_userId_idx').on(table.userId),
142 index('agent_hostId_idx').on(table.hostId),
143 index('agent_status_idx').on(table.status),
144 index('agent_kid_idx').on(table.kid),
145 ],
147​
148export const agentCapabilityGrant = sqliteTable(
149 'agent_capability_grant',
150 {
151 id: text('id').primaryKey(),
152 agentId: text('agent_id')
153 .notNull()
154 .references(() => agent.id, { onDelete: 'cascade' }),
155 capability: text('capability').notNull(),
156 deniedBy: text('denied_by').references(() => user.id, {
157 onDelete: 'cascade',
158 }),
159 grantedBy: text('granted_by').references(() => user.id, {
160 onDelete: 'cascade',
161 }),
162 expiresAt: integer('expires_at', { mode: 'timestamp_ms' }),
163 createdAt: integer('created_at', { mode: 'timestamp_ms' }).notNull(),
164 updatedAt: integer('updated_at', { mode: 'timestamp_ms' }).notNull(),
165 status: text('status').default('active').notNull(),
166 reason: text('reason'),
167 constraints: text('constraints'),
168 },
169 (table) => [
170 index('agentCapabilityGrant_agentId_idx').on(table.agentId),
171 index('agentCapabilityGrant_capability_idx').on(table.capability),
172 index('agentCapabilityGrant_grantedBy_idx').on(table.grantedBy),
173 index('agentCapabilityGrant_status_idx').on(table.status),
174 ],
176​
177export const approvalRequest = sqliteTable(
178 'approval_request',
179 {
180 id: text('id').primaryKey(),
181 method: text('method').notNull(),
182 agentId: text('agent_id').references(() => agent.id, {
183 onDelete: 'cascade',
184 }),
185 hostId: text('host_id').references(() => agentHost.id, {
186 onDelete: 'cascade',
187 }),
188 userId: text('user_id').references(() => user.id, { onDelete: 'cascade' }),
189 capabilities: text('capabilities'),
190 status: text('status').default('pending').notNull(),
191 userCodeHash: text('user_code_hash'),
192 loginHint: text('login_hint'),
193 bindingMessage: text('binding_message'),
194 clientNotificationToken: text('client_notification_token'),
195 clientNotificationEndpoint: text('client_notification_endpoint'),
196 deliveryMode: text('delivery_mode'),
197 interval: integer('interval').notNull(),
198 lastPolledAt: integer('last_polled_at', { mode: 'timestamp_ms' }),
199 expiresAt: integer('expires_at', { mode: 'timestamp_ms' }).notNull(),
200 createdAt: integer('created_at', { mode: 'timestamp_ms' }).notNull(),
201 updatedAt: integer('updated_at', { mode: 'timestamp_ms' }).notNull(),
202 },
203 (table) => [
204 index('approvalRequest_agentId_idx').on(table.agentId),
205 index('approvalRequest_hostId_idx').on(table.hostId),
206 index('approvalRequest_userId_idx').on(table.userId),
207 index('approvalRequest_status_idx').on(table.status),
208 ],
210​
211export const apikey = sqliteTable(
212 'apikey',
213 {
214 id: text('id').primaryKey(),
215 configId: text('config_id').default('default').notNull(),
216 name: text('name'),
217 start: text('start'),
218 referenceId: text('reference_id').notNull(),
219 prefix: text('prefix'),
220 key: text('key').notNull(),
221 refillInterval: integer('refill_interval'),
222 refillAmount: integer('refill_amount'),
223 lastRefillAt: integer('last_refill_at', { mode: 'timestamp_ms' }),
224 enabled: integer('enabled', { mode: 'boolean' }).default(true),
225 rateLimitEnabled: integer('rate_limit_enabled', {
226 mode: 'boolean',
227 }).default(true),
228 rateLimitTimeWindow: integer('rate_limit_time_window').default(86400000),
229 rateLimitMax: integer('rate_limit_max').default(10),
230 requestCount: integer('request_count').default(0),
231 remaining: integer('remaining'),
232 lastRequest: integer('last_request', { mode: 'timestamp_ms' }),
233 expiresAt: integer('expires_at', { mode: 'timestamp_ms' }),
234 createdAt: integer('created_at', { mode: 'timestamp_ms' }).notNull(),
235 updatedAt: integer('updated_at', { mode: 'timestamp_ms' }).notNull(),
236 permissions: text('permissions'),
237 metadata: text('metadata'),
238 },
239 (table) => [
240 index('apikey_configId_idx').on(table.configId),
241 index('apikey_referenceId_idx').on(table.referenceId),
242 index('apikey_key_idx').on(table.key),
243 ],
245​
246export const userRelations = relations(user, ({ many }) => ({
247 sessions: many(session),
248 accounts: many(account),
249 agentHosts: many(agentHost),
250 agents: many(agent),
251 agentCapabilityGrants: many(agentCapabilityGrant),
252 approvalRequests: many(approvalRequest),
253}))
254​
255export const sessionRelations = relations(session, ({ one }) => ({
256 user: one(user, {
257 fields: [session.userId],
258 references: [user.id],
259 }),
260}))
261​
262export const accountRelations = relations(account, ({ one }) => ({
263 user: one(user, {
264 fields: [account.userId],
265 references: [user.id],
266 }),
267}))
268​
269export const agentHostRelations = relations(agentHost, ({ one, many }) => ({
270 user: one(user, {
271 fields: [agentHost.userId],
272 references: [user.id],
273 }),
274 agents: many(agent),
275 approvalRequests: many(approvalRequest),
276}))
277​
278export const agentRelations = relations(agent, ({ one, many }) => ({
279 user: one(user, {
280 fields: [agent.userId],
281 references: [user.id],
282 }),
283 agentHost: one(agentHost, {
284 fields: [agent.hostId],
285 references: [agentHost.id],
286 }),
287 agentCapabilityGrants: many(agentCapabilityGrant),
288 approvalRequests: many(approvalRequest),
289}))
290​
291export const agentCapabilityGrantDeniedByRelations = relations(
292 agentCapabilityGrant,
293 ({ one }) => ({
294 user: one(user, {
295 fields: [agentCapabilityGrant.deniedBy],
296 references: [user.id],
297 }),
298 }),
300​
301export const agentCapabilityGrantGrantedByRelations = relations(
302 agentCapabilityGrant,
303 ({ one }) => ({
304 user: one(user, {
305 fields: [agentCapabilityGrant.grantedBy],
306 references: [user.id],
307 }),
308 }),
310​
311export const agentCapabilityGrantRelations = relations(
312 agentCapabilityGrant,
313 ({ one }) => ({
314 agent: one(agent, {
315 fields: [agentCapabilityGrant.agentId],
316 references: [agent.id],
317 }),
318 }),
320​
321export const approvalRequestRelations = relations(
322 approvalRequest,
323 ({ one }) => ({
324 agent: one(agent, {
325 fields: [approvalRequest.agentId],
326 references: [agent.id],
327 }),
328 agentHost: one(agentHost, {
329 fields: [approvalRequest.hostId],
330 references: [agentHost.id],
331 }),
332 user: one(user, {
333 fields: [approvalRequest.userId],
334 references: [user.id],
335 }),
336 }),
338​
339// ---------------------------------------------------------------------------
340// Core domain tables (PLAN.md task 1.1).
341// Conventions: ids are lowercase kebab/slug text; times are unix epoch seconds
342// (plain integers — the timestamp_ms columns above are better-auth-generated).
343// ---------------------------------------------------------------------------
344​
345export const activities = [
346 'chat',
347 'image',
348 'video',
349 'audio',
350 'embeddings',
351 'moderation',
352] as const
353export type Activity = (typeof activities)[number]
354​
355export const changeTypes = [
356 'model.added',
357 'model.removed',
358 'model.updated',
359 'catalog.shape_changed',
360 'schema.added',
361 'schema.updated',
362 'endpoint.added',
363 'endpoint.removed',
364] as const
365export type ChangeType = (typeof changeTypes)[number]
366​
367export const providers = sqliteTable('providers', {
368 id: text('id').primaryKey(),
369 displayName: text('display_name').notNull(),
370 specSourceUrl: text('spec_source_url').notNull(),
371 modelsEndpoint: text('models_endpoint'),
372 authEnvVar: text('auth_env_var'),
373 lastPolledAt: integer('last_polled_at'),
374 lastSyncedAt: integer('last_synced_at'),
375 status: text('status', {
376 enum: ['active', 'degraded', 'disabled'],
377 })
378 .notNull()
379 .default('active'),
380})
381​
382/** Names other providers' model ids use for a provider (`google` → gemini). */
383export const providerModelNamespaces = sqliteTable(
384 'provider_model_namespaces',
385 {
386 namespace: text('namespace').notNull(),
387 providerId: text('provider_id')
388 .notNull()
389 .references(() => providers.id, { onDelete: 'cascade' }),
390 },
391 (table) => [
392 primaryKey({ columns: [table.namespace, table.providerId] }),
393 index('provider_model_namespaces_providerId_idx').on(table.providerId),
394 ],
396​
397export const models = sqliteTable(
398 'models',
399 {
400 id: text('id').primaryKey(),
401 providerId: text('provider_id')
402 .notNull()
403 .references(() => providers.id, { onDelete: 'cascade' }),
404 rawId: text('raw_id').notNull(),
405 activity: text('activity', { enum: activities }),
406 displayName: text('display_name'),
407 contextWindow: integer('context_window'),
408 maxOutput: integer('max_output'),
409 modalities: text('modalities', { mode: 'json' }),
410 pricing: text('pricing', { mode: 'json' }),
411 // A flag map: `{ tools: true, reasoning: false }`. true = the provider
412 // states support, false = it states none, key absent = unknown, null =
413 // nothing known. Booleans only.
414 capabilities: text('capabilities', {
415 mode: 'json',
416 }).$type<CapabilityMap | null>(),
417 // The provider's own listing object, as published and not normalised
418 // (fal category, Ark features, ElevenLabs languages, …). Never flags.
419 providerMetadata: text('provider_metadata', { mode: 'json' }).$type<Record<
420 string,
421 unknown
422 > | null>(),
423 // Thinking configuration and provider-hosted tool type ids (issue #77).
424 reasoning: text('reasoning', { mode: 'json' }),
425 serverTools: text('server_tools', { mode: 'json' }),
426 // Wire map for thinking, token limits, and roles (issue #95). Null until
427 // verified. `reasoning` stays the readable fact.
428 requestMap: text('request_map', { mode: 'json' }),
429 // Caller ids that resolve to this dated row (issue #112).
430 aliases: text('aliases', { mode: 'json' }).$type<Array<string> | null>(),
431 // The provider's own statement of its upstream model (issue #199); it
432 // can precede the target row's arrival. The namespace resolves through
433 // providers / provider_model_namespaces.
434 upstreamProvider: text('upstream_provider'),
435 upstreamRawId: text('upstream_raw_id'),
436 upstreamSource: text('upstream_source', { mode: 'json' }),
437 // Resolved link, written only by reconcileSameAs; never the row's facts.
438 sameAsModelId: text('same_as_model_id').references(
439 (): AnySQLiteColumn => models.id,
440 { onDelete: 'set null' },
441 ),
442 // Per-field provenance for catalog facts (issue #53). JSON ModelFactSources.
443 factSources: text('fact_sources', { mode: 'json' }),
444 // Generation route decided from listing data the read path cannot see
445 // (Gemini's supportedGenerationMethods → :predict vs :generateContent).
446 // Null → config binds at read time; Gemini still reads leftover
447 // methods from capabilities until the poller rewrites the row.
448 schemaEndpointId: text('schema_endpoint_id'),
449 // The provider's own stated release/created date; null when it reports
450 // none. `firstSeenAt` below folds the same date in and cannot say which.
451 releasedAt: integer('released_at'),
452 // `YYYY-MM` or `YYYY-MM-DD`, as precise as the provider states it.
453 knowledgeCutoff: text('knowledge_cutoff'),
454 // Stated by the provider itself, never inferred; null = unstated.
455 openWeights: integer('open_weights', { mode: 'boolean' }),
456 weightsUrl: text('weights_url'),
457 // Upstream release date when the provider reports one (backdated by the
458 // poller, issue #1); otherwise when our poller first observed the model.
459 firstSeenAt: integer('first_seen_at').notNull(),
460 lastSeenAt: integer('last_seen_at').notNull(),
461 deprecatedAt: integer('deprecated_at'),
462 },
463 (table) => [
464 index('models_providerId_idx').on(table.providerId),
465 index('models_activity_idx').on(table.activity),
466 index('models_sameAsModelId_idx').on(table.sameAsModelId),
467 check(
468 'models_upstream_identity_pair',
469 sql`(${table.upstreamProvider} IS NULL) = (${table.upstreamRawId} IS NULL)
470 AND (${table.upstreamProvider} IS NULL) = (${table.upstreamSource} IS NULL)`,
471 ),
472 check('models_sameAs_not_self', sql`${table.sameAsModelId} != ${table.id}`),
473 ],
475​
476export const endpoints = sqliteTable(
477 'endpoints',
478 {
479 id: text('id').primaryKey(),
480 providerId: text('provider_id')
481 .notNull()
482 .references(() => providers.id, { onDelete: 'cascade' }),
483 activity: text('activity', { enum: activities }).notNull(),
484 method: text('method').notNull(),
485 path: text('path').notNull(),
486 description: text('description'),
487 },
488 (table) => [index('endpoints_providerId_idx').on(table.providerId)],
490​
491export const schemaVersions = sqliteTable(
492 'schema_versions',
493 {
494 id: text('id').primaryKey(),
495 endpointId: text('endpoint_id')
496 .notNull()
497 .references(() => endpoints.id, { onDelete: 'cascade' }),
498 kind: text('kind', { enum: ['input', 'output'] }).notNull(),
499 contentHash: text('content_hash').notNull(),
500 schema: text('schema').notNull(),
501 specRevision: text('spec_revision'),
502 // Provenance (nullable on rows synced before it was recorded): the
503 // upstream document this version was derived from, and the extractor
504 // that derived it. createdAt doubles as the fetched-at timestamp.
505 sourceUrl: text('source_url'),
506 sourceHash: text('source_hash'),
507 extractorVersion: text('extractor_version'),
508 /**
509 * How the content was arrived at — the `Derivation` trust ladder in
510 * `src/server/providers/types.ts`. Nullable on rows synced before it was
511 * recorded. `verifiedAt` is a `YYYY-MM-DD` date and is only meaningful
512 * for `probe-verified`, whose accuracy is a point-in-time claim.
513 */
514 derivation: text('derivation', {
515 enum: ['upstream-spec', 'generated', 'probe-verified', 'docs-derived'],
516 }),
517 verifiedAt: text('verified_at'),
518 createdAt: integer('created_at').notNull(),
519 supersededAt: integer('superseded_at'),
520 },
521 (table) => [
522 index('schema_versions_endpointId_kind_idx').on(
523 table.endpointId,
524 table.kind,
525 ),
526 index('schema_versions_contentHash_idx').on(table.contentHash),
527 ],
529​
530export const changes = sqliteTable(
531 'changes',
532 {
533 id: text('id').primaryKey(),
534 type: text('type', { enum: changeTypes }).notNull(),
535 providerId: text('provider_id')
536 .notNull()
537 .references(() => providers.id, { onDelete: 'cascade' }),
538 subjectId: text('subject_id').notNull(),
539 summary: text('summary').notNull(),
540 payload: text('payload', { mode: 'json' }),
541 createdAt: integer('created_at').notNull(),
542 },
543 (table) => [
544 index('changes_createdAt_idx').on(table.createdAt),
545 index('changes_providerId_idx').on(table.providerId),
546 ],
548​
549export const providersRelations = relations(providers, ({ many }) => ({
550 models: many(models),
551 endpoints: many(endpoints),
552 changes: many(changes),
553}))
554​
555export const modelsRelations = relations(models, ({ one }) => ({
556 provider: one(providers, {
557 fields: [models.providerId],
558 references: [providers.id],
559 }),
560}))
561​
562export const endpointsRelations = relations(endpoints, ({ one, many }) => ({
563 provider: one(providers, {
564 fields: [endpoints.providerId],
565 references: [providers.id],
566 }),
567 schemaVersions: many(schemaVersions),
568}))
569​
570export const schemaVersionsRelations = relations(schemaVersions, ({ one }) => ({
571 endpoint: one(endpoints, {
572 fields: [schemaVersions.endpointId],
573 references: [endpoints.id],
574 }),
575}))
576​
577export const changesRelations = relations(changes, ({ one }) => ({
578 provider: one(providers, {
579 fields: [changes.providerId],
580 references: [providers.id],
581 }),
582}))
583​
584// ---------------------------------------------------------------------------
585// Cache + delivery tables (PLAN.md task 1.2).
586// ---------------------------------------------------------------------------
587​
588export const cacheMeta = sqliteTable('cache_meta', {
589 key: text('key').primaryKey(),
590 fetchedAt: integer('fetched_at').notNull(),
591 staleTime: integer('stale_time').notNull(),
592 lastError: text('last_error'),
593 refreshing: integer('refreshing', { mode: 'boolean' })
594 .notNull()
595 .default(false),
596})
597​
598export const subscriptions = sqliteTable(
599 'subscriptions',
600 {
601 id: text('id').primaryKey(),
602 agentId: text('agent_id')
603 .notNull()
604 .references(() => user.id, { onDelete: 'cascade' }),
605 url: text('url').notNull(),
606 secret: text('secret').notNull(),
607 events: text('events', { mode: 'json' }).notNull(),
608 providerFilter: text('provider_filter').references(() => providers.id, {
609 onDelete: 'cascade',
610 }),
611 active: integer('active', { mode: 'boolean' }).notNull().default(true),
612 createdAt: integer('created_at').notNull(),
613 },
614 (table) => [index('subscriptions_agentId_idx').on(table.agentId)],
616​
617export const webhookDeliveries = sqliteTable(
618 'webhook_deliveries',
619 {
620 id: text('id').primaryKey(),
621 subscriptionId: text('subscription_id')
622 .notNull()
623 .references(() => subscriptions.id, { onDelete: 'cascade' }),
624 changeId: text('change_id')
625 .notNull()
626 .references(() => changes.id, { onDelete: 'cascade' }),
627 attempt: integer('attempt').notNull().default(0),
628 nextAttemptAt: integer('next_attempt_at').notNull(),
629 status: text('status', { enum: ['pending', 'ok', 'failed'] })
630 .notNull()
631 .default('pending'),
632 lastResponseCode: integer('last_response_code'),
633 },
634 (table) => [
635 index('webhook_deliveries_status_nextAttemptAt_idx').on(
636 table.status,
637 table.nextAttemptAt,
638 ),
639 index('webhook_deliveries_subscriptionId_idx').on(table.subscriptionId),
640 ],
642​
643export const subscriptionsRelations = relations(
644 subscriptions,
645 ({ one, many }) => ({
646 agent: one(user, {
647 fields: [subscriptions.agentId],
648 references: [user.id],
649 }),
650 deliveries: many(webhookDeliveries),
651 }),
653​
654export const webhookDeliveriesRelations = relations(
655 webhookDeliveries,
656 ({ one }) => ({
657 subscription: one(subscriptions, {
658 fields: [webhookDeliveries.subscriptionId],
659 references: [subscriptions.id],
660 }),
661 change: one(changes, {
662 fields: [webhookDeliveries.changeId],
663 references: [changes.id],
664 }),
665 }),