import { createClient } from '@supabase/supabase-js';

const supabaseUrl = 'https://jqklhhpyykzrktikjnmb.supabase.co';
const supabaseAnonKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Impxa2xoaHB5eWt6cmt0aWtqbm1iIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjgzODQ0MDgsImV4cCI6MjA4Mzk2MDQwOH0.QsPuBnyUtRPSavlqKj3IGR9c8juT02LY_hSi-j3c6M0';

const supabase = createClient(supabaseUrl, supabaseAnonKey);

async function check() {
    const { data, error } = await supabase.from('profiles').select('*').limit(0);
    const { data: cols, error: colError } = await supabase.rpc('get_table_columns', { table_name: 'profiles' });
    
    // If RPC doesn't exist, try a different way
    if (colError) {
        console.log("RPC Error (likely doesn't exist):", colError.message);
        // Try to insert a row with a wrong column to see what columns exist in the error message? No.
        // Let's just try to select one of each suspected column.
        const { data: testData, error: testError } = await supabase.from('shops').select('*').limit(1);
        if (testError) {
            console.log("SELECT ERROR:", testError.message);
        } else {
            console.log("COLUMNS EXIST IN SHOPS:", testData && testData.length > 0 ? Object.keys(testData[0]) : "No rows");
        }
    } else {
        console.log("COLUMNS:", cols);
    }
    process.exit(0);
}

check();
