/**
 * Initialize Config Table with Default Values
 */

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

const initConfig = async () => {
  try {
    console.log('Initializing config table...');
    
    // Test database connection
    await sequelize.authenticate();
    console.log('Database connection established');
    
    // Initialize default configurations
    await configService.initializeDefaults();
    console.log('✓ Default configurations initialized successfully');
    
    // Display current configs
    const configs = await configService.getAllConfigs();
    console.log('\nCurrent configurations:');
    configs.forEach(config => {
      console.log(`  ${config.key}: ${config.value || '(empty)'} [${config.type}]`);
    });
    
    process.exit(0);
  } catch (error) {
    console.error('Error initializing config:', error);
    process.exit(1);
  }
};

initConfig();
