备份:修复前完整项目快照 2026-04-19
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
const db = require('./backend/db-sqlite');
|
||||
async function fix() {
|
||||
const fixes = [
|
||||
// Purchase requests
|
||||
"ALTER TABLE purchase_requests ADD COLUMN request_date TEXT DEFAULT ''",
|
||||
// Products
|
||||
"ALTER TABLE products ADD COLUMN remark TEXT DEFAULT ''",
|
||||
// Payment plans - make purchase_order_id nullable
|
||||
// Can't alter NOT NULL in SQLite, so we'll handle it in the route
|
||||
// Customers - the is_default might be queried from wrong table
|
||||
// Let's check the actual customers table schema
|
||||
];
|
||||
|
||||
for (const sql of fixes) {
|
||||
try { await db.query(sql); console.log('OK:', sql.substring(0, 80)); }
|
||||
catch(e) {
|
||||
const msg = e.message || '';
|
||||
if (msg.includes('duplicate') || msg.includes('already exists')) {
|
||||
console.log('SKIP:', sql.substring(0, 80));
|
||||
} else {
|
||||
console.log('ERR:', msg.substring(0, 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check customers table schema
|
||||
try {
|
||||
const schema = await db.query("PRAGMA table_info(customers)");
|
||||
console.log('\nCustomers columns:', schema.rows.map(r => r.name).join(', '));
|
||||
} catch(e) { console.log('ERR:', e.message); }
|
||||
|
||||
// Check payment_plans schema
|
||||
try {
|
||||
const schema = await db.query("PRAGMA table_info(payment_plans)");
|
||||
console.log('Payment plans columns:', schema.rows.map(r => `${r.name}[${r.notnull?'NOT NULL':'NULL'}]`).join(', '));
|
||||
} catch(e) { console.log('ERR:', e.message); }
|
||||
|
||||
process.exit();
|
||||
}
|
||||
fix();
|
||||
Reference in New Issue
Block a user