diff --git a/backend-node/scripts/run-1050-migration.js b/backend-node/scripts/run-1050-migration.js new file mode 100644 index 00000000..aa1b3723 --- /dev/null +++ b/backend-node/scripts/run-1050-migration.js @@ -0,0 +1,35 @@ +/** + * system_notice 테이블 생성 마이그레이션 실행 + */ +const { Pool } = require('pg'); +const fs = require('fs'); +const path = require('path'); + +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'); + await client.query(sql); + console.log('OK: system_notice 테이블 생성 완료'); + + // 검증 + const result = await client.query( + "SELECT column_name FROM information_schema.columns WHERE table_name='system_notice' ORDER BY ordinal_position" + ); + console.log('컬럼:', result.rows.map(r => r.column_name).join(', ')); + } catch (e) { + console.error('ERROR:', e.message); + process.exit(1); + } finally { + client.release(); + await pool.end(); + } +} + +run();