81 lines
2.3 KiB
JavaScript
81 lines
2.3 KiB
JavaScript
const sqlite3 = require('sqlite3').verbose();
|
|
const path = require('path');
|
|
|
|
const dbPath = path.join(__dirname, 'company_finance.db');
|
|
const db = new sqlite3.Database(dbPath);
|
|
|
|
console.log('检查数据库表...');
|
|
|
|
db.all("SELECT name FROM sqlite_master WHERE type='table'", (err, tables) => {
|
|
if (err) {
|
|
console.error('查询失败:', err);
|
|
return;
|
|
}
|
|
|
|
console.log('所有表:');
|
|
tables.forEach(table => {
|
|
console.log(`- ${table.name}`);
|
|
|
|
// 检查每个表的结构
|
|
db.all(`PRAGMA table_info(${table.name})`, (err, columns) => {
|
|
if (err) {
|
|
console.error(` 查询表结构失败: ${err.message}`);
|
|
return;
|
|
}
|
|
console.log(` 列: ${columns.map(c => c.name).join(', ')}`);
|
|
});
|
|
});
|
|
|
|
// 检查预算相关表
|
|
db.all("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%budget%'", (err, budgetTables) => {
|
|
console.log('\n预算相关表:');
|
|
if (budgetTables.length === 0) {
|
|
console.log('- 无');
|
|
} else {
|
|
budgetTables.forEach(table => {
|
|
console.log(`- ${table.name}`);
|
|
});
|
|
}
|
|
});
|
|
|
|
// 检查施工相关表
|
|
db.all("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%construction%'", (err, constructionTables) => {
|
|
console.log('\n施工相关表:');
|
|
if (constructionTables.length === 0) {
|
|
console.log('- 无');
|
|
} else {
|
|
constructionTables.forEach(table => {
|
|
console.log(`- ${table.name}`);
|
|
});
|
|
}
|
|
});
|
|
|
|
// 检查付款请求表
|
|
db.all("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%payment%'", (err, paymentTables) => {
|
|
console.log('\n付款相关表:');
|
|
if (paymentTables.length === 0) {
|
|
console.log('- 无');
|
|
} else {
|
|
paymentTables.forEach(table => {
|
|
console.log(`- ${table.name}`);
|
|
});
|
|
}
|
|
});
|
|
|
|
// 检查汇率表
|
|
db.all("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%exchange%'", (err, exchangeTables) => {
|
|
console.log('\n汇率相关表:');
|
|
if (exchangeTables.length === 0) {
|
|
console.log('- 无');
|
|
} else {
|
|
exchangeTables.forEach(table => {
|
|
console.log(`- ${table.name}`);
|
|
});
|
|
}
|
|
});
|
|
|
|
setTimeout(() => {
|
|
db.close();
|
|
console.log('\n检查完成');
|
|
}, 1000);
|
|
}); |