29 lines
905 B
JavaScript
29 lines
905 B
JavaScript
import mysql from 'mysql2/promise';
|
|
import dotenv from 'dotenv';
|
|
|
|
dotenv.config();
|
|
|
|
const { DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_PORT } = process.env;
|
|
|
|
async function checkRecentLogs() {
|
|
const connection = await mysql.createConnection({
|
|
host: DB_HOST,
|
|
user: DB_USER,
|
|
password: DB_PASS,
|
|
database: DB_NAME,
|
|
port: parseInt(DB_PORT || '3306')
|
|
});
|
|
|
|
console.log('--- Recent History Logs ---');
|
|
const [rows] = await connection.query('SELECT * FROM asset_history ORDER BY created_at DESC LIMIT 5');
|
|
console.log(JSON.stringify(rows, null, 2));
|
|
|
|
console.log('\n--- Recent Core Data (to check current_dept) ---');
|
|
const [coreRows] = await connection.query('SELECT id, asset_code, current_dept, previous_dept FROM asset_core ORDER BY updated_at DESC LIMIT 5');
|
|
console.log(JSON.stringify(coreRows, null, 2));
|
|
|
|
await connection.end();
|
|
}
|
|
|
|
checkRecentLogs().catch(console.error);
|