const { sequelize } = require('./config/db');
require('./models/Pet'); // Load models

const syncDB = async () => {
  try {
    console.log('Connecting to DB...');
    await sequelize.authenticate();
    console.log('Connected. Syncing schema...');

    // Force alter to ensure columns are added
    await sequelize.sync({ alter: true });

    console.log('Schema update complete. Checking Pet table columns...');

    // Check columns
    const [results] = await sequelize.query('DESCRIBE Pets;');
    console.log('Table Structure:', results.map(r => r.Field));

    process.exit(0);
  } catch (error) {
    console.error('Sync failed:', error);
    process.exit(1);
  }
};

syncDB();
