require('dotenv').config();
const { createClient } = require('@supabase/supabase-js');
const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_SERVICE_KEY);

async function checkDB() {
  // Check tasks table
  const { data: tasks } = await supabase.from('tasks').select('*').limit(1);
  console.log('TASKS columns:', tasks?.[0] ? Object.keys(tasks[0]) : 'No tasks');
  
  // Check submissions table
  const { data: subs } = await supabase.from('submissions').select('*').limit(1);
  console.log('SUBMISSIONS columns:', subs?.[0] ? Object.keys(subs[0]) : 'No submissions');
  
  // Check users table
  const { data: users } = await supabase.from('app_users').select('*').limit(1);
  console.log('USERS columns:', users?.[0] ? Object.keys(users[0]) : 'No users');
  
  // Count tasks
  const { count: taskCount } = await supabase.from('tasks').select('*', { count: 'exact', head: true });
  console.log('Total tasks:', taskCount);
  
  // Count active tasks
  const { count: activeCount } = await supabase.from('tasks').select('*', { count: 'exact', head: true }).in('status', ['open', 'active']);
  console.log('Active tasks:', activeCount);
  
  process.exit(0);
}
checkDB();
