This commit is contained in:
phaichayon
2026-06-27 10:04:43 +07:00
parent 2ace5dbb83
commit 3fdd681dd0
29 changed files with 8593 additions and 15 deletions

View File

@@ -766,6 +766,9 @@ export const crmApprovalSteps = pgTable(
roleName: text('role_name').notNull(),
approvalMode: text('approval_mode').default('sequential').notNull(),
isRequired: boolean('is_required').default(true).notNull(),
slaHours: integer('sla_hours').default(24).notNull(),
calendarMode: text('calendar_mode').default('calendar_days').notNull(),
timeoutAction: text('timeout_action').default('none').notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
deletedAt: timestamp('deleted_at', { withTimezone: true })
@@ -806,6 +809,9 @@ export const crmApprovalRequests = pgTable('crm_approval_requests', {
entityType: text('entity_type').notNull(),
entityId: text('entity_id').notNull(),
currentStep: integer('current_step').default(1).notNull(),
currentStepStartedAt: timestamp('current_step_started_at', { withTimezone: true })
.defaultNow()
.notNull(),
status: text('status').notNull(),
requestedBy: text('requested_by').notNull(),
requestedAt: timestamp('requested_at', { withTimezone: true }).defaultNow().notNull(),
@@ -815,6 +821,48 @@ export const crmApprovalRequests = pgTable('crm_approval_requests', {
deletedAt: timestamp('deleted_at', { withTimezone: true })
});
export const crmApprovalReminderPolicies = pgTable(
'crm_approval_reminder_policies',
{
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull(),
workflowId: text('workflow_id').notNull(),
stepNumber: integer('step_number').notNull(),
slaHours: integer('sla_hours').default(24).notNull(),
reminderOffsetsHours: integer('reminder_offsets_hours').array().default([]).notNull(),
calendarMode: text('calendar_mode').default('calendar_days').notNull(),
timeoutAction: text('timeout_action').default('none').notNull(),
isActive: boolean('is_active').default(true).notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
deletedAt: timestamp('deleted_at', { withTimezone: true }),
createdBy: text('created_by').notNull(),
updatedBy: text('updated_by').notNull()
},
(table) => ({
workflowStepIdx: uniqueIndex('crm_approval_reminder_policies_workflow_step_idx').on(
table.workflowId,
table.stepNumber
)
})
);
export const crmApprovalEscalationPolicies = pgTable('crm_approval_escalation_policies', {
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull(),
workflowId: text('workflow_id').notNull(),
stepNumber: integer('step_number').notNull(),
triggerAfterHours: integer('trigger_after_hours').notNull(),
targetType: text('target_type').notNull(),
targetValue: text('target_value'),
isActive: boolean('is_active').default(true).notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
deletedAt: timestamp('deleted_at', { withTimezone: true }),
createdBy: text('created_by').notNull(),
updatedBy: text('updated_by').notNull()
});
export const crmApprovalActions = pgTable('crm_approval_actions', {
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull(),