setup email

This commit is contained in:
phaichayon
2026-07-06 23:07:55 +07:00
parent d93f25e1ce
commit 18cc9bbfd0
30 changed files with 8907 additions and 156 deletions

View File

@@ -265,6 +265,39 @@ export const documentSequences = pgTable(
})
);
export const emailConfigurations = pgTable(
'email_configurations',
{
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull(),
providerType: text('provider_type').default('smtp').notNull(),
name: text('name').notNull(),
host: text('host').notNull(),
port: integer('port').default(587).notNull(),
secure: boolean('secure').default(false).notNull(),
username: text('username'),
passwordEncrypted: text('password_encrypted'),
fromEmail: text('from_email').notNull(),
fromName: text('from_name'),
replyToEmail: text('reply_to_email'),
isDefault: boolean('is_default').default(false).notNull(),
isActive: boolean('is_active').default(true).notNull(),
lastTestStatus: text('last_test_status').default('not_tested').notNull(),
lastTestedAt: timestamp('last_tested_at', { withTimezone: true }),
lastTestError: text('last_test_error'),
createdBy: text('created_by').notNull(),
updatedBy: text('updated_by').notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull()
},
(table) => ({
organizationNameIdx: uniqueIndex('email_configurations_org_name_idx').on(
table.organizationId,
table.name
)
})
);
export const trAuditLogs = pgTable('tr_audit_logs', {
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull(),