summaryrefslogtreecommitdiff
path: root/db/schema
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-08-14 11:54:47 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-08-14 11:54:47 +0000
commit969c25b56f6d29d7ffa4bc2ce04c5fb4e5846b34 (patch)
tree551d335e850e6163792ded0e7a75fa41d96d612a /db/schema
parentdd20ba9785cdbd3d61f6b014d003d3bd9646ad13 (diff)
(대표님) 정규벤더등록, 벤더문서관리, 벤더데이터입력, 첨부파일관리
Diffstat (limited to 'db/schema')
-rw-r--r--db/schema/vendorDocu.ts28
-rw-r--r--db/schema/vendorRegistrations.ts5
2 files changed, 20 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
diff --git a/db/schema/vendorRegistrations.ts b/db/schema/vendorRegistrations.ts
index 308d664f..d6030a75 100644
--- a/db/schema/vendorRegistrations.ts
+++ b/db/schema/vendorRegistrations.ts
@@ -8,6 +8,7 @@ import {
timestamp,
varchar,
decimal,
+ boolean,
} from "drizzle-orm/pg-core";
import { vendors } from "./vendors";
@@ -24,6 +25,10 @@ export const vendorRegularRegistrations = pgTable("vendor_regular_registrations"
assignedUser: varchar("assigned_user", { length: 100 }), // 담당자
assignedUserCode: varchar("assigned_user_code", { length: 20 }), // 담당자코드
remarks: text("remarks"), // 비고
+ // 안전적격성 평가 관련
+ safetyQualificationContent: text("safety_qualification_content"), // 안전적격성 평가 내용
+ // GTC Skip 관련
+ gtcSkipped: boolean("gtc_skipped").notNull().default(false), // GTC Skip 여부
createdAt: timestamp("created_at").defaultNow(),
updatedAt: timestamp("updated_at").defaultNow(),
});