const { createClient } = require('@supabase/supabase-js');
const fs = require('fs');
const path = require('path');

const supabaseUrl = process.env.SUPABASE_URL;
const supabaseKey = process.env.SUPABASE_SERVICE_KEY;
const supabase = createClient(supabaseUrl, supabaseKey);

async function setupDatabase() {
  try {
    const sql = fs.readFileSync(path.join(__dirname, 'supabase_setup.sql'), 'utf8');
    const { error } = await supabase.rpc('exec', { sql });
    if (error) {
      console.error('Error setting up database:', error);
    } else {
      console.log('Database setup complete.');
    }
  } catch (error) {
    console.error('Error reading setup file:', error);
  }
}

setupDatabase();
