diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-08-14 11:54:47 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-08-14 11:54:47 +0000 |
| commit | 969c25b56f6d29d7ffa4bc2ce04c5fb4e5846b34 (patch) | |
| tree | 551d335e850e6163792ded0e7a75fa41d96d612a /db/schema/vendorDocu.ts | |
| parent | dd20ba9785cdbd3d61f6b014d003d3bd9646ad13 (diff) | |
(대표님) 정규벤더등록, 벤더문서관리, 벤더데이터입력, 첨부파일관리
Diffstat (limited to 'db/schema/vendorDocu.ts')
| -rw-r--r-- | db/schema/vendorDocu.ts | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/db/schema/vendorDocu.ts b/db/schema/vendorDocu.ts index 58c0ad29..789f2cd7 100644 --- a/db/schema/vendorDocu.ts +++ b/db/schema/vendorDocu.ts @@ -652,7 +652,7 @@ export const syncConfigs = pgTable( "sync_configs", { id: serial("id").primaryKey(), - projectId: integer("project_id").notNull(), + vendorId: integer("vendor_id").notNull(), targetSystem: varchar("target_system", { length: 50 }).notNull(), // 'SHI', 'SAP' 등 syncEnabled: boolean("sync_enabled").default(true), @@ -670,7 +670,7 @@ export const syncConfigs = pgTable( (table) => { return { contractSystemIdx: index("idx_sync_configs_contract_system").on( - table.projectId, + table.vendorId, table.targetSystem ), } @@ -682,7 +682,7 @@ export const changeLogs = pgTable( "change_logs", { id: serial("id").primaryKey(), - projectId: integer("project_id").notNull(), + vendorId: integer("vendor_id").notNull(), entityType: varchar("entity_type", { length: 50 }).notNull(), // 'document', 'revision', 'attachment' entityId: integer("entity_id").notNull(), @@ -701,8 +701,8 @@ export const changeLogs = pgTable( }, (table) => { return { - projectSyncedIdx: index("idx_change_logs_project_synced").on( - table.projectId, + vendorSyncedIdx: index("idx_change_logs_vendor_synced").on( + table.vendorId, table.isSynced ), createdAtIdx: index("idx_change_logs_created_at").on(table.createdAt), @@ -717,7 +717,7 @@ export const syncBatches = pgTable( "sync_batches", { id: serial("id").primaryKey(), - projectId: integer("project_id").notNull(), + vendorId: integer("vendor_id").notNull(), targetSystem: varchar("target_system", { length: 50 }).notNull(), batchSize: integer("batch_size").notNull(), @@ -736,7 +736,7 @@ export const syncBatches = pgTable( (table) => { return { projectSystemIdx: index("idx_sync_batches_project_system").on( - table.projectId, + table.vendorId, table.targetSystem ), statusIdx: index("idx_sync_batches_status").on(table.status), @@ -747,7 +747,7 @@ export const syncBatches = pgTable( // 동기화 상태 추적을 위한 뷰 export const syncStatusView = pgView("sync_status_view", { - projectId: integer("project_id").notNull(), + vendorId: integer("vendor_id").notNull(), targetSystem: varchar("target_system", { length: 50 }).notNull(), totalChanges: integer("total_changes").notNull(), pendingChanges: integer("pending_changes").notNull(), @@ -759,7 +759,7 @@ export const syncStatusView = pgView("sync_status_view", { }).as(sql` WITH change_stats AS ( SELECT - cl.project_id, + cl.vendor_id, sc.target_system, COUNT(*) as total_changes, COUNT(CASE WHEN cl.is_synced = false AND cl.sync_attempts < sc.retry_max_attempts THEN 1 END) as pending_changes, @@ -768,12 +768,12 @@ export const syncStatusView = pgView("sync_status_view", { MAX(cl.synced_at) as last_sync_at FROM change_logs cl CROSS JOIN sync_configs sc - WHERE cl.project_id = sc.project_id + WHERE cl.vendor_id = sc.vendor_id AND (cl.target_systems IS NULL OR cl.target_systems @> to_jsonb(ARRAY[sc.target_system])) - GROUP BY cl.project_id, sc.target_system + GROUP BY cl.vendor_id, sc.target_system ) SELECT - cs.project_id, + cs.vendor_id, cs.target_system, COALESCE(cs.total_changes, 0) as total_changes, COALESCE(cs.pending_changes, 0) as pending_changes, @@ -787,7 +787,7 @@ export const syncStatusView = pgView("sync_status_view", { END as next_sync_at, sc.sync_enabled FROM sync_configs sc - LEFT JOIN change_stats cs ON sc.project_id = cs.project_id AND sc.target_system = cs.target_system + LEFT JOIN change_stats cs ON sc.vendor_id = cs.vendor_id AND sc.target_system = cs.target_system `) // 타입 추출 @@ -897,6 +897,7 @@ export const simplifiedDocumentsView = pgView("simplified_documents_view", { filePath: string; fileSize: number | null; fileType: string | null; + dolceFilePath: string | null; createdAt: Date; updatedAt: Date; }>; @@ -922,6 +923,7 @@ export const simplifiedDocumentsView = pgView("simplified_documents_view", { 'filePath', da.file_path, 'fileSize', da.file_size, 'fileType', da.file_type, + 'dolceFilePath', da.dolce_file_path, 'createdAt', da.created_at, 'updatedAt', da.updated_at ) ORDER BY da.created_at |
