task-ep.1.1

This commit is contained in:
phaichayon
2026-07-10 10:33:45 +07:00
parent f47fea5d6f
commit 9ae4f31f28
33 changed files with 9680 additions and 22 deletions

View File

@@ -674,6 +674,48 @@ export const crmOpportunityFollowups = pgTable('crm_opportunity_followups', {
updatedBy: text('updated_by').notNull()
});
export const crmActivities = pgTable('crm_activities', {
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull(),
primaryEntityType: text('primary_entity_type').notNull(),
primaryEntityId: text('primary_entity_id'),
primaryRecordLabel: text('primary_record_label'),
relatedRecords: jsonb('related_records').default([]).notNull(),
customerId: text('customer_id'),
contactId: text('contact_id'),
leadId: text('lead_id'),
opportunityId: text('opportunity_id'),
quotationId: text('quotation_id'),
activityType: text('activity_type').notNull(),
subject: text('subject').notNull(),
description: text('description'),
ownerId: text('owner_id').notNull(),
assignedToId: text('assigned_to_id'),
scheduledStartAt: timestamp('scheduled_start_at', { withTimezone: true }),
scheduledEndAt: timestamp('scheduled_end_at', { withTimezone: true }),
dueAt: timestamp('due_at', { withTimezone: true }),
completedAt: timestamp('completed_at', { withTimezone: true }),
cancelledAt: timestamp('cancelled_at', { withTimezone: true }),
skippedAt: timestamp('skipped_at', { withTimezone: true }),
status: text('status').notNull(),
priority: text('priority').notNull(),
outcomeSummary: text('outcome_summary'),
cancellationReason: text('cancellation_reason'),
skipReason: text('skip_reason'),
nextAction: text('next_action'),
branchId: text('branch_id'),
productType: text('product_type'),
isInternalOnly: boolean('is_internal_only').default(false).notNull(),
isPricingSensitive: boolean('is_pricing_sensitive').default(false).notNull(),
parentActivityId: text('parent_activity_id'),
metadata: jsonb('metadata'),
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 crmOpportunityCustomers = pgTable('crm_opportunity_customers', {
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull(),