const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('inventory.db');

console.log('=== DATABASE STRUCTURE CHECK ===');

// Check customers table
db.all('PRAGMA table_info(customers)', [], (err, rows) => {
    console.log('\nCustomers table columns:');
    rows.forEach(row => {
        console.log(`  ${row.name} (${row.type}) ${row.notnull ? 'NOT NULL' : ''}`);
    });
});

// Check credit_payments table
db.all('PRAGMA table_info(credit_payments)', [], (err, rows) => {
    console.log('\nCredit payments table columns:');
    rows.forEach(row => {
        console.log(`  ${row.name} (${row.type}) ${row.notnull ? 'NOT NULL' : ''}`);
    });
});

// Check data counts
db.all('SELECT COUNT(*) as count FROM customers', [], (err, rows) => {
    console.log(`\nCustomers count: ${rows[0].count}`);
});

db.all('SELECT COUNT(*) as count FROM transactions', [], (err, rows) => {
    console.log(`Transactions count: ${rows[0].count}`);
});

db.all('SELECT COUNT(*) as count FROM credit_payments', [], (err, rows) => {
    console.log(`Credit payments count: ${rows[0].count}`);
    db.close();
});