const { Sequelize, DataTypes } = require('sequelize'); const config = require('./database/config.js').development; const path = require('path'); const fs = require('fs'); async function run() { try { const sequelize = new Sequelize(config.database, config.username, config.password, { host: config.host, port: config.port, dialect: 'mysql', logging: false, }); const queryInterface = sequelize.getQueryInterface(); const tables = await queryInterface.showAllTables(); console.log('Tables:', tables.join(', ')); const [ meta ] = tables.includes('SequelizeMeta') ? await sequelize.query("SELECT name FROM SequelizeMeta WHERE name = '20260525113000-add-request-platform-code-to-wms-print-platform.js'") : [[]]; console.log('Initial Migration recorded:', meta.length > 0); const migration = require('./database/migrations/20260525113000-add-request-platform-code-to-wms-print-platform.js'); console.log('Executing migration up...'); try { await migration.up(queryInterface, Sequelize); } catch (e) { console.log('Migration up info:', e.message); } if (!tables.includes('SequelizeMeta')) { await sequelize.query('CREATE TABLE SequelizeMeta (name VARCHAR(255) NOT NULL PRIMARY KEY) ENGINE=InnoDB;'); } await sequelize.query("INSERT IGNORE INTO SequelizeMeta (name) VALUES ('20260525113000-add-request-platform-code-to-wms-print-platform.js')"); const tableInfo = await queryInterface.describeTable('wms_print_platform'); const col = tableInfo.request_platform_code; console.log('Result Column request_platform_code:', col ? JSON.stringify({ type: col.type, allowNull: col.allowNull, defaultValue: col.defaultValue }) : 'NOT FOUND'); const [ finalMeta ] = await sequelize.query("SELECT name FROM SequelizeMeta WHERE name = '20260525113000-add-request-platform-code-to-wms-print-platform.js'"); console.log('Final Migration recorded:', finalMeta.length > 0); await sequelize.close(); } catch (err) { console.error('Error:', err.message); process.exit(1); } } run();