ตรวจสอบแก้ไชสร้างเอกสาร
This commit is contained in:
@@ -255,10 +255,17 @@ export const appNotificationTemplates = pgTable(
|
||||
id: text('id').primaryKey(),
|
||||
organizationId: text('organization_id').notNull(),
|
||||
eventType: text('event_type').notNull(),
|
||||
code: text('code').default('').notNull(),
|
||||
name: text('name').default('').notNull(),
|
||||
channel: text('channel').notNull(),
|
||||
subjectTemplate: text('subject_template'),
|
||||
titleTemplate: text('title_template').notNull(),
|
||||
bodyTemplate: text('body_template').notNull(),
|
||||
bodyFormat: text('body_format').default('plain').notNull(),
|
||||
linkTemplate: text('link_template'),
|
||||
language: text('language').default('th').notNull(),
|
||||
variables: jsonb('variables'),
|
||||
version: integer('version').default(1).notNull(),
|
||||
isActive: boolean('is_active').default(true).notNull(),
|
||||
metadata: jsonb('metadata'),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
|
||||
@@ -276,6 +283,45 @@ export const appNotificationTemplates = pgTable(
|
||||
})
|
||||
);
|
||||
|
||||
export const appNotificationDispatches = pgTable(
|
||||
'app_notification_dispatches',
|
||||
{
|
||||
id: text('id').primaryKey(),
|
||||
organizationId: text('organization_id').notNull(),
|
||||
eventId: text('event_id').notNull(),
|
||||
templateId: text('template_id'),
|
||||
entityType: text('entity_type').notNull(),
|
||||
entityId: text('entity_id').notNull(),
|
||||
channel: text('channel').notNull(),
|
||||
providerKey: text('provider_key').notNull(),
|
||||
status: text('status').default('pending').notNull(),
|
||||
recipientTo: jsonb('recipient_to').notNull(),
|
||||
recipientCc: jsonb('recipient_cc'),
|
||||
recipientBcc: jsonb('recipient_bcc'),
|
||||
replyTo: text('reply_to'),
|
||||
subject: text('subject').notNull(),
|
||||
bodyText: text('body_text').notNull(),
|
||||
bodyHtml: text('body_html'),
|
||||
attachments: jsonb('attachments'),
|
||||
recipientUserId: text('recipient_user_id'),
|
||||
recipientAddress: text('recipient_address'),
|
||||
requestedBy: text('requested_by').notNull(),
|
||||
metadata: jsonb('metadata'),
|
||||
lastError: text('last_error'),
|
||||
retryCount: integer('retry_count').default(0).notNull(),
|
||||
maxRetryCount: integer('max_retry_count').default(3).notNull(),
|
||||
lastAttemptAt: timestamp('last_attempt_at', { withTimezone: true }),
|
||||
sentAt: timestamp('sent_at', { withTimezone: true }),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull()
|
||||
},
|
||||
(table) => ({
|
||||
organizationEventChannelRecipientIdx: uniqueIndex(
|
||||
'app_notification_dispatches_org_event_channel_recipient_idx'
|
||||
).on(table.organizationId, table.eventId, table.channel, table.recipientAddress)
|
||||
})
|
||||
);
|
||||
|
||||
export const appNotificationDeliveries = pgTable('app_notification_deliveries', {
|
||||
id: text('id').primaryKey(),
|
||||
organizationId: text('organization_id').notNull(),
|
||||
|
||||
Reference in New Issue
Block a user