init
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
const { sequelize } = require('../config/database');
|
||||
|
||||
async function checkDatabaseTables() {
|
||||
try {
|
||||
// 데이터베이스 연결
|
||||
await sequelize.authenticate();
|
||||
console.log('데이터베이스 연결 성공');
|
||||
|
||||
// 모든 테이블 목록 조회
|
||||
const [tables] = await sequelize.query('SHOW TABLES');
|
||||
|
||||
console.log('데이터베이스 테이블 목록:');
|
||||
tables.forEach(table => {
|
||||
const tableName = Object.values(table)[0];
|
||||
console.log(`- ${tableName}`);
|
||||
});
|
||||
|
||||
// 각 테이블의 구조 확인
|
||||
for (const table of tables) {
|
||||
const tableName = Object.values(table)[0];
|
||||
const [columns] = await sequelize.query(`DESCRIBE \`${tableName}\``);
|
||||
|
||||
console.log(`\n테이블: ${tableName}`);
|
||||
columns.forEach(column => {
|
||||
console.log(` - ${column.Field}: ${column.Type} ${column.Null === 'NO' ? 'NOT NULL' : 'NULL'} ${column.Key === 'PRI' ? 'PRIMARY KEY' : ''}`);
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('오류 발생:', error);
|
||||
} finally {
|
||||
// 연결 종료
|
||||
await sequelize.close();
|
||||
}
|
||||
}
|
||||
|
||||
// 스크립트 실행
|
||||
checkDatabaseTables();
|
||||
Reference in New Issue
Block a user