import { createClient } from '@/utils/supabase/server';

const tables = [
    'days',
    'hours',
    'colors',
    'categories',
    'metrics',
    'measurements'
];

export default async function UpdateUserIdsPage() {
    const supabase = await createClient();
    const USERID = '1240aecb-a352-482c-a49a-9b45e166691a';

    for (const table of tables) {
        const { data: schema } = await supabase.from(table).select();
        for (const row of schema!) {
            if (!row.userId) {
                // Update userId in supabase
                await supabase.from(table).update({ userId: USERID }).eq("id", schema!.id);
                console.log(`Updated row: ${row.id} in table: ${table}`);
            }
        };
    }

    return <pre>Updated tables.</pre>
}
