uat-doc-perfix

This commit is contained in:
phaichayon
2026-06-30 14:48:34 +07:00
parent 9698228c51
commit 47eac3badc
28 changed files with 2518 additions and 996 deletions

View File

@@ -158,19 +158,28 @@ export const documentSequences = pgTable(
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull(),
branchId: text('branch_id').default('').notNull(),
productType: text('product_type').default('all').notNull(),
documentType: text('document_type').notNull(),
prefix: text('prefix').notNull(),
period: text('period').notNull(),
currentNumber: integer('current_number').default(0).notNull(),
paddingLength: integer('padding_length').default(3).notNull(),
format: text('format').default('{prefix}{period}-{running}').notNull(),
resetPolicy: text('reset_policy').default('period').notNull(),
isActive: boolean('is_active').default(true).notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull()
},
(table) => ({
organizationDocumentPeriodBranchIdx: uniqueIndex(
'document_sequences_org_doc_period_branch_idx'
).on(table.organizationId, table.documentType, table.period, table.branchId)
organizationBranchProductDocumentPeriodIdx: uniqueIndex(
'document_sequences_org_branch_product_doc_period_idx'
).on(
table.organizationId,
table.branchId,
table.productType,
table.documentType,
table.period
)
})
);