Files
ITAM/expand_pc_schema.js
Taehoon 82bbe85e23 feat: migrate ServerPC data to asset_pc, enhance filters with location, and standardize page headers
- 서버PC 자산을 asset_pc 테이블로 통합 마이그레이션 및 스키마 확장 (위치, IP 정보 복구 완료)

- 하드웨어 자산 페이지의 구매법인 필터를 자산위치 필터로 교체 및 동적 데이터 바인딩 적용

- 모든 자산 리스트 페이지 상단에 설명(Description) 필드 추가 및 헤더 표준화

- 상세 모달 내 삭제 버튼 기능 구현 및 서버PC 용도 필드 노출 오류 수정

- 현 사용조직 필터 리스트가 비어있던 DOM 셀렉터 버그 수정
2026-05-26 17:33:03 +09:00

53 lines
1.6 KiB
JavaScript
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 mysql from 'mysql2/promise';
import dotenv from 'dotenv';
dotenv.config();
async function expandSchema() {
const connection = await mysql.createConnection({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASS,
database: process.env.DB_NAME,
port: parseInt(process.env.DB_PORT || '3306')
});
try {
console.log('🏗️ Expanding asset_pc table schema...');
const columnsToAdd = [
{ name: 'location', type: 'TEXT' },
{ name: 'location_detail', type: 'TEXT' },
{ name: 'ip_address', type: 'TEXT' },
{ name: 'ip_address_2', type: 'TEXT' },
{ name: 'remote_tool', type: 'TEXT' },
{ name: 'remote_id', type: 'TEXT' },
{ name: 'remote_pw', type: 'TEXT' },
{ name: 'monitoring', type: 'TEXT' },
{ name: 'asset_purpose', type: 'TEXT' }
];
for (const col of columnsToAdd) {
try {
await connection.query(`ALTER TABLE asset_pc ADD COLUMN \`${col.name}\` ${col.type}`);
console.log(`✅ Added column: ${col.name}`);
} catch (err) {
if (err.code === 'ER_DUP_COLUMN_NAME') {
console.log(` Column ${col.name} already exists.`);
} else {
throw err;
}
}
}
console.log('🎉 Schema expansion completed!');
} catch (err) {
console.error('❌ Schema expansion failed:', err);
} finally {
await connection.end();
}
}
expandSchema();