task-ep.1.6
This commit is contained in:
@@ -676,6 +676,87 @@ export const crmTimelineProjection = pgTable(
|
||||
})
|
||||
);
|
||||
|
||||
export const crmCalendarProjection = pgTable(
|
||||
'crm_calendar_projection',
|
||||
{
|
||||
id: text('id').primaryKey(),
|
||||
organizationId: text('organization_id').notNull(),
|
||||
branchId: text('branch_id'),
|
||||
productType: text('product_type'),
|
||||
customerId: text('customer_id'),
|
||||
leadId: text('lead_id'),
|
||||
opportunityId: text('opportunity_id'),
|
||||
quotationId: text('quotation_id'),
|
||||
approvalId: text('approval_id'),
|
||||
activityId: text('activity_id'),
|
||||
ownerId: text('owner_id'),
|
||||
assigneeId: text('assignee_id'),
|
||||
eventId: text('event_id').notNull(),
|
||||
entityType: text('entity_type').notNull(),
|
||||
entityId: text('entity_id').notNull(),
|
||||
title: text('title').notNull(),
|
||||
summary: text('summary'),
|
||||
location: text('location'),
|
||||
startAt: timestamp('start_at', { withTimezone: true }).notNull(),
|
||||
endAt: timestamp('end_at', { withTimezone: true }).notNull(),
|
||||
timezone: text('timezone').default('Asia/Bangkok').notNull(),
|
||||
priority: text('priority').default('normal').notNull(),
|
||||
category: text('category').notNull(),
|
||||
activityType: text('activity_type'),
|
||||
editable: boolean('editable').default(false).notNull(),
|
||||
milestone: boolean('milestone').default(false).notNull(),
|
||||
overdue: boolean('overdue').default(false).notNull(),
|
||||
hotProject: boolean('hot_project').default(false).notNull(),
|
||||
allDay: boolean('all_day').default(false).notNull(),
|
||||
visibility: jsonb('visibility').notNull(),
|
||||
metadata: jsonb('metadata'),
|
||||
sourceEvent: jsonb('source_event').notNull(),
|
||||
sourceProjectionVersion: integer('source_projection_version').default(1).notNull(),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull()
|
||||
},
|
||||
(table) => ({
|
||||
eventVersionIdx: uniqueIndex('crm_calendar_projection_event_version_idx').on(
|
||||
table.eventId,
|
||||
table.sourceProjectionVersion
|
||||
),
|
||||
organizationStartIdx: index('crm_calendar_projection_org_start_idx').on(
|
||||
table.organizationId,
|
||||
table.startAt
|
||||
),
|
||||
organizationAssigneeStartIdx: index('crm_calendar_projection_org_assignee_start_idx').on(
|
||||
table.organizationId,
|
||||
table.assigneeId,
|
||||
table.startAt
|
||||
),
|
||||
organizationOwnerStartIdx: index('crm_calendar_projection_org_owner_start_idx').on(
|
||||
table.organizationId,
|
||||
table.ownerId,
|
||||
table.startAt
|
||||
),
|
||||
organizationBranchStartIdx: index('crm_calendar_projection_org_branch_start_idx').on(
|
||||
table.organizationId,
|
||||
table.branchId,
|
||||
table.startAt
|
||||
),
|
||||
organizationCategoryStartIdx: index('crm_calendar_projection_org_category_start_idx').on(
|
||||
table.organizationId,
|
||||
table.category,
|
||||
table.startAt
|
||||
),
|
||||
customerStartIdx: index('crm_calendar_projection_customer_start_idx').on(
|
||||
table.organizationId,
|
||||
table.customerId,
|
||||
table.startAt
|
||||
),
|
||||
activityEventIdx: index('crm_calendar_projection_activity_event_idx').on(
|
||||
table.organizationId,
|
||||
table.activityId,
|
||||
table.eventId
|
||||
)
|
||||
})
|
||||
);
|
||||
|
||||
export const crmCustomers = pgTable(
|
||||
'crm_customers',
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user