diff --git a/backend-node/scripts/run-notice-migration.js b/backend-node/scripts/run-notice-migration.js new file mode 100644 index 00000000..4b23153d --- /dev/null +++ b/backend-node/scripts/run-notice-migration.js @@ -0,0 +1,38 @@ +/** + * system_notice 마이그레이션 실행 스크립트 + * 사용법: node scripts/run-notice-migration.js + */ +const fs = require('fs'); +const path = require('path'); +const { Pool } = require('pg'); + +const pool = new Pool({ + connectionString: process.env.DATABASE_URL || 'postgresql://postgres:ph0909!!@39.117.244.52:11132/plm', + ssl: false, +}); + +async function run() { + const client = await pool.connect(); + try { + const sqlPath = path.join(__dirname, '../../db/migrations/1050_create_system_notice.sql'); + const sql = fs.readFileSync(sqlPath, 'utf8'); + + console.log('마이그레이션 실행 중...'); + await client.query(sql); + console.log('마이그레이션 완료'); + + // 컬럼 확인 + const check = await client.query( + "SELECT column_name FROM information_schema.columns WHERE table_name='system_notice' ORDER BY ordinal_position" + ); + console.log('테이블 컬럼:', check.rows.map(r => r.column_name).join(', ')); + } catch (e) { + console.error('오류:', e.message); + process.exit(1); + } finally { + client.release(); + await pool.end(); + } +} + +run();