로그시스템 개선

This commit is contained in:
kjs
2025-10-27 11:11:08 +09:00
parent f14d9ee66c
commit 5fdefffd26
12 changed files with 1588 additions and 93 deletions

View File

@@ -1,4 +1,6 @@
import { PostgreSQLService } from './PostgreSQLService';
import { PostgreSQLService } from "./PostgreSQLService";
import fs from "fs";
import path from "path";
/**
* 데이터베이스 마이그레이션 실행
@@ -6,21 +8,21 @@ import { PostgreSQLService } from './PostgreSQLService';
*/
export async function runDashboardMigration() {
try {
console.log('🔄 대시보드 마이그레이션 시작...');
console.log("🔄 대시보드 마이그레이션 시작...");
// custom_title 컬럼 추가
await PostgreSQLService.query(`
ALTER TABLE dashboard_elements
ADD COLUMN IF NOT EXISTS custom_title VARCHAR(255)
`);
console.log('✅ custom_title 컬럼 추가 완료');
console.log("✅ custom_title 컬럼 추가 완료");
// show_header 컬럼 추가
await PostgreSQLService.query(`
ALTER TABLE dashboard_elements
ADD COLUMN IF NOT EXISTS show_header BOOLEAN DEFAULT true
`);
console.log('✅ show_header 컬럼 추가 완료');
console.log("✅ show_header 컬럼 추가 완료");
// 기존 데이터 업데이트
await PostgreSQLService.query(`
@@ -28,15 +30,83 @@ export async function runDashboardMigration() {
SET show_header = true
WHERE show_header IS NULL
`);
console.log('✅ 기존 데이터 업데이트 완료');
console.log("✅ 기존 데이터 업데이트 완료");
console.log('✅ 대시보드 마이그레이션 완료!');
console.log("✅ 대시보드 마이그레이션 완료!");
} catch (error) {
console.error('❌ 대시보드 마이그레이션 실패:', error);
console.error("❌ 대시보드 마이그레이션 실패:", error);
// 이미 컬럼이 있는 경우는 무시
if (error instanceof Error && error.message.includes('already exists')) {
console.log(' 컬럼이 이미 존재합니다.');
if (error instanceof Error && error.message.includes("already exists")) {
console.log(" 컬럼이 이미 존재합니다.");
}
}
}
/**
* 테이블 이력 보기 버튼 액션 마이그레이션
*/
export async function runTableHistoryActionMigration() {
try {
console.log("🔄 테이블 이력 보기 액션 마이그레이션 시작...");
// SQL 파일 읽기
const sqlFilePath = path.join(
__dirname,
"../../db/migrations/024_add_table_history_view_action.sql"
);
if (!fs.existsSync(sqlFilePath)) {
console.log("⚠️ 마이그레이션 파일이 없습니다:", sqlFilePath);
return;
}
const sqlContent = fs.readFileSync(sqlFilePath, "utf8");
// SQL 실행
await PostgreSQLService.query(sqlContent);
console.log("✅ 테이블 이력 보기 액션 마이그레이션 완료!");
} catch (error) {
console.error("❌ 테이블 이력 보기 액션 마이그레이션 실패:", error);
// 이미 액션이 있는 경우는 무시
if (
error instanceof Error &&
error.message.includes("duplicate key value")
) {
console.log(" 액션이 이미 존재합니다.");
}
}
}
/**
* DTG Management 테이블 이력 시스템 마이그레이션
*/
export async function runDtgManagementLogMigration() {
try {
console.log("🔄 DTG Management 이력 테이블 마이그레이션 시작...");
// SQL 파일 읽기
const sqlFilePath = path.join(
__dirname,
"../../db/migrations/025_create_dtg_management_log.sql"
);
if (!fs.existsSync(sqlFilePath)) {
console.log("⚠️ 마이그레이션 파일이 없습니다:", sqlFilePath);
return;
}
const sqlContent = fs.readFileSync(sqlFilePath, "utf8");
// SQL 실행
await PostgreSQLService.query(sqlContent);
console.log("✅ DTG Management 이력 테이블 마이그레이션 완료!");
} catch (error) {
console.error("❌ DTG Management 이력 테이블 마이그레이션 실패:", error);
// 이미 테이블이 있는 경우는 무시
if (error instanceof Error && error.message.includes("already exists")) {
console.log(" 이력 테이블이 이미 존재합니다.");
}
}
}