mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 18:25:24 +02:00
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
import { createClient } from '@supabase/supabase-js';
|
|||
|
|
import dotenv from 'dotenv';
|
||
|
|
dotenv.config({ path: '.env.local' });
|
||
|
|
|
||
|
|
const supabase = createClient(
|
||
|
|
process.env.VITE_SUPABASE_URL || '',
|
||
|
|
process.env.VITE_SUPABASE_SERVICE_KEY || process.env.VITE_SUPABASE_ANON_KEY || ''
|
||
|
|
);
|
||
|
|
|
||
|
|
async function testUpdate() {
|
||
|
|
// Grab the first active experiment
|
||
|
|
const { data: exps, error: err1 } = await supabase.from('experiments').select('*').limit(1);
|
||
|
|
if (err1 || !exps?.length) {
|
||
|
|
console.log('No experiments found or error:', err1);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
const exp = exps[0];
|
||
|
|
console.log('Testing update on:', exp.id, exp.name);
|
||
|
|
|
||
|
|
// Try to push a dummy update just for the new columns
|
||
|
|
const { data, error } = await supabase
|
||
|
|
.from('experiments')
|
||
|
|
.update({
|
||
|
|
experiment_acos: 15.5,
|
||
|
|
experiment_cvr: 10.2,
|
||
|
|
updated_at: new Date().toISOString()
|
||
|
|
})
|
||
|
|
.eq('id', exp.id)
|
||
|
|
.select()
|
||
|
|
.single();
|
||
|
|
|
||
|
|
if (error) {
|
||
|
|
console.error('Supabase Error:', error);
|
||
|
|
} else {
|
||
|
|
console.log('Success!', data);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
testUpdate();
|