/**
 * 远程数据库连接测试与列出表名
 */
const { sequelize } = require('../config/database');

(async () => {
  try {
    console.log('Connecting to DB...', {
      dialect: process.env.DB_DIALECT,
      host: process.env.DB_HOST,
      port: process.env.DB_PORT,
      database: process.env.DB_NAME,
      user: process.env.DB_USER
    });

    await sequelize.authenticate();
    console.log('✅ DB connected');

    const [rows] = await sequelize.query('SHOW TABLES');
    const tables = rows.map(r => Object.values(r)[0]);
    console.log('📋 Tables:', tables);

    process.exit(0);
  } catch (err) {
    console.error('❌ DB connect failed:', err.message);
    process.exit(1);
  }
})();

