const { sequelize } = require('../config/database');

const updateCategoryNames = async () => {
  const categories = [
    { key: 'airport', name_zh: '机场接送', name_en: 'Airport Transfer', name_pt: 'Transferência de Aeroporto' },
    { key: 'train', name_zh: '火车站接送', name_en: 'Train Station Transfer', name_pt: 'Transferência de Estação de Trem' },
    { key: 'high-speed-rail', name_zh: '高铁站接送', name_en: 'High-Speed Rail Transfer', name_pt: 'Transferência de Trem de Alta Velocidade' },
    { key: 'bus', name_zh: '汽车站接送', name_en: 'Bus Station Transfer', name_pt: 'Transferência de Estação de Ônibus' },
    { key: 'hotel', name_zh: '酒店预订', name_en: 'Hotel Booking', name_pt: 'Reserva de Hotel' },
    { key: 'homestay', name_zh: '民宿预订', name_en: 'Homestay Booking', name_pt: 'Reserva de Casa de Família' }
  ];

  try {
    for (const category of categories) {
      const [result] = await sequelize.query(
        'UPDATE category SET name_zh = ?, name_en = ?, name_pt = ? WHERE `key` = ?',
        {
          replacements: [category.name_zh, category.name_en, category.name_pt, category.key]
        }
      );
      
      console.log(`Updated ${category.key}: ${result.affectedRows || 0} rows`);
    }
    
    console.log('All categories updated successfully!');
  } catch (error) {
    console.error('Error updating categories:', error);
  } finally {
    await sequelize.close();
    process.exit(0);
  }
};

updateCategoryNames();
