diff --git a/backend-node/src/app.ts b/backend-node/src/app.ts index 1d1ad9a6..9d286648 100644 --- a/backend-node/src/app.ts +++ b/backend-node/src/app.ts @@ -345,11 +345,13 @@ app.listen(PORT, HOST, async () => { runDashboardMigration, runTableHistoryActionMigration, runDtgManagementLogMigration, + runApprovalSystemMigration, } = await import("./database/runMigration"); await runDashboardMigration(); await runTableHistoryActionMigration(); await runDtgManagementLogMigration(); + await runApprovalSystemMigration(); } catch (error) { logger.error(`❌ 마이그레이션 실패:`, error); } diff --git a/backend-node/src/database/runMigration.ts b/backend-node/src/database/runMigration.ts index a1bb2ec5..07f714d6 100644 --- a/backend-node/src/database/runMigration.ts +++ b/backend-node/src/database/runMigration.ts @@ -2,6 +2,37 @@ import { PostgreSQLService } from "./PostgreSQLService"; import fs from "fs"; import path from "path"; +/** + * 결재 시스템 테이블 마이그레이션 + * approval_definitions, approval_line_templates, approval_line_template_steps, + * approval_requests, approval_lines 테이블 생성 + */ +export async function runApprovalSystemMigration() { + try { + console.log("🔄 결재 시스템 마이그레이션 시작..."); + + const sqlFilePath = path.join( + __dirname, + "../../db/migrations/100_create_approval_system.sql" + ); + + if (!fs.existsSync(sqlFilePath)) { + console.log("⚠️ 마이그레이션 파일이 없습니다:", sqlFilePath); + return; + } + + const sqlContent = fs.readFileSync(sqlFilePath, "utf8"); + await PostgreSQLService.query(sqlContent); + + console.log("✅ 결재 시스템 마이그레이션 완료!"); + } catch (error) { + console.error("❌ 결재 시스템 마이그레이션 실패:", error); + if (error instanceof Error && error.message.includes("already exists")) { + console.log("ℹ️ 테이블이 이미 존재합니다."); + } + } +} + /** * 데이터베이스 마이그레이션 실행 * dashboard_elements 테이블에 custom_title, show_header 컬럼 추가