const db = require('./config/database');
const fs = require('fs');

async function setupParentChildrenTable() {
  try {
    console.log('Setting up parent_children table...');
    
    const sql = fs.readFileSync('./create_parent_children_table.sql', 'utf8');
    const statements = sql.split(';').filter(stmt => stmt.trim());
    
    for (const statement of statements) {
      if (statement.trim()) {
        await db.execute(statement);
        console.log('✅ Executed:', statement.substring(0, 50) + '...');
      }
    }
    
    console.log('✅ Parent-children table setup completed successfully!');
    
  } catch (error) {
    console.error('❌ Error setting up parent_children table:', error.message);
  } finally {
    process.exit(0);
  }
}

setupParentChildrenTable();