task-g
This commit is contained in:
101
src/db/schema.ts
101
src/db/schema.ts
@@ -465,3 +465,104 @@ export const crmApprovalActions = pgTable('crm_approval_actions', {
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
|
||||
deletedAt: timestamp('deleted_at', { withTimezone: true })
|
||||
});
|
||||
|
||||
export const crmDocumentTemplates = pgTable(
|
||||
'crm_document_templates',
|
||||
{
|
||||
id: text('id').primaryKey(),
|
||||
organizationId: text('organization_id').notNull(),
|
||||
documentType: text('document_type').notNull(),
|
||||
productType: text('product_type').notNull(),
|
||||
fileType: text('file_type').notNull(),
|
||||
templateName: text('template_name').notNull(),
|
||||
description: text('description'),
|
||||
isDefault: boolean('is_default').default(false).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) => ({
|
||||
organizationTemplateIdx: uniqueIndex('crm_document_templates_org_doc_product_file_name_idx').on(
|
||||
table.organizationId,
|
||||
table.documentType,
|
||||
table.productType,
|
||||
table.fileType,
|
||||
table.templateName
|
||||
)
|
||||
})
|
||||
);
|
||||
|
||||
export const crmDocumentTemplateVersions = pgTable(
|
||||
'crm_document_template_versions',
|
||||
{
|
||||
id: text('id').primaryKey(),
|
||||
organizationId: text('organization_id').notNull(),
|
||||
templateId: text('template_id').notNull(),
|
||||
version: text('version').notNull(),
|
||||
filePath: text('file_path'),
|
||||
schemaJson: jsonb('schema_json').notNull(),
|
||||
previewImageUrl: text('preview_image_url'),
|
||||
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()
|
||||
},
|
||||
(table) => ({
|
||||
templateVersionIdx: uniqueIndex('crm_document_template_versions_template_version_idx').on(
|
||||
table.templateId,
|
||||
table.version
|
||||
)
|
||||
})
|
||||
);
|
||||
|
||||
export const crmDocumentTemplateMappings = pgTable(
|
||||
'crm_document_template_mappings',
|
||||
{
|
||||
id: text('id').primaryKey(),
|
||||
organizationId: text('organization_id').notNull(),
|
||||
templateVersionId: text('template_version_id').notNull(),
|
||||
placeholderKey: text('placeholder_key').notNull(),
|
||||
sourcePath: text('source_path').notNull(),
|
||||
dataType: text('data_type').notNull(),
|
||||
sheetName: text('sheet_name'),
|
||||
defaultValue: text('default_value'),
|
||||
formatMask: text('format_mask'),
|
||||
sortOrder: integer('sort_order').default(0).notNull(),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
|
||||
deletedAt: timestamp('deleted_at', { withTimezone: true })
|
||||
},
|
||||
(table) => ({
|
||||
templatePlaceholderIdx: uniqueIndex('crm_document_template_mappings_version_placeholder_idx').on(
|
||||
table.templateVersionId,
|
||||
table.placeholderKey
|
||||
)
|
||||
})
|
||||
);
|
||||
|
||||
export const crmDocumentTemplateTableColumns = pgTable(
|
||||
'crm_document_template_table_columns',
|
||||
{
|
||||
id: text('id').primaryKey(),
|
||||
organizationId: text('organization_id').notNull(),
|
||||
mappingId: text('mapping_id').notNull(),
|
||||
columnName: text('column_name').notNull(),
|
||||
sourceField: text('source_field').notNull(),
|
||||
columnLetter: text('column_letter'),
|
||||
sortOrder: integer('sort_order').default(0).notNull(),
|
||||
formatMask: text('format_mask'),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
|
||||
deletedAt: timestamp('deleted_at', { withTimezone: true })
|
||||
},
|
||||
(table) => ({
|
||||
mappingColumnIdx: uniqueIndex('crm_document_template_table_columns_mapping_name_idx').on(
|
||||
table.mappingId,
|
||||
table.columnName
|
||||
)
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user