Files
vexplor/backend-node/src/database/runMigration.ts
leeheejin 6d51aced2c 위젯 커스텀 제목 및 헤더 표시/숨김 기능 추가
- 위젯 설정에서 제목 변경 가능
- 위젯 헤더 표시/숨김 토글 추가
- DB 마이그레이션 자동 실행 (custom_title, show_header 컬럼)
- 편집 모드/보기 모드 모두 지원
- DashboardTopMenu 레이아웃 유지
2025-10-16 14:59:07 +09:00

43 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { PostgreSQLService } from './PostgreSQLService';
/**
* 데이터베이스 마이그레이션 실행
* dashboard_elements 테이블에 custom_title, show_header 컬럼 추가
*/
export async function runDashboardMigration() {
try {
console.log('🔄 대시보드 마이그레이션 시작...');
// custom_title 컬럼 추가
await PostgreSQLService.query(`
ALTER TABLE dashboard_elements
ADD COLUMN IF NOT EXISTS custom_title VARCHAR(255)
`);
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 컬럼 추가 완료');
// 기존 데이터 업데이트
await PostgreSQLService.query(`
UPDATE dashboard_elements
SET show_header = true
WHERE show_header IS NULL
`);
console.log('✅ 기존 데이터 업데이트 완료');
console.log('✅ 대시보드 마이그레이션 완료!');
} catch (error) {
console.error('❌ 대시보드 마이그레이션 실패:', error);
// 이미 컬럼이 있는 경우는 무시
if (error instanceof Error && error.message.includes('already exists')) {
console.log(' 컬럼이 이미 존재합니다.');
}
}
}