WMS_MAIN/query_db.js
liufumingren abf2c4d94a 1
2026-05-29 16:47:38 +08:00

40 lines
1.4 KiB
JavaScript

const mysql = require('mysql2/promise');
const config = require('./database/config.js').development;
async function run() {
const connection = await mysql.createConnection({
host: config.host,
port: config.port,
user: config.username,
password: config.password,
database: config.database,
});
try {
// 1) CONNECTION
const [ connRows ] = await connection.execute('SELECT DATABASE() AS db, @@hostname AS hostname, @@port AS port');
console.log(`CONNECTION=${JSON.stringify(connRows[0])}`);
// 2) META
const [ metaRows ] = await connection.execute("SELECT name FROM SequelizeMeta WHERE name='20260525113000-add-request-platform-code-to-wms-print-platform.js'");
console.log(`META=${JSON.stringify(metaRows[0] || null)}`);
// 3) COLUMNS
const [ columnRows ] = await connection.execute("SHOW COLUMNS FROM wms_print_platform LIKE 'request_platform_code'");
console.log(`COLUMNS=${JSON.stringify(columnRows[0] || null)}`);
// 4) CREATE_LINE
const [ createRows ] = await connection.execute('SHOW CREATE TABLE wms_print_platform');
const createTableStmt = createRows[0]['Create Table'];
const createLine = createTableStmt.split('\n').find(line => line.includes('request_platform_code')) || null;
console.log(`CREATE_LINE=${createLine ? createLine.trim() : null}`);
} catch (err) {
console.error(err);
} finally {
await connection.end();
}
}
run();