-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_pg.js
More file actions
36 lines (31 loc) · 1.22 KB
/
check_pg.js
File metadata and controls
36 lines (31 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { createClient } = require('@supabase/supabase-js');
const fs = require('fs');
require('dotenv').config();
const supabaseAdmin = createClient(
process.env.SUPABASE_URL || '',
process.env.SUPABASE_SERVICE_ROLE_KEY || '',
{
auth: {
autoRefreshToken: false,
persistSession: false
}
}
);
async function runMigration() {
try {
const sql = fs.readFileSync('./database/gamification.sql', 'utf8');
const { error } = await supabaseAdmin.rpc('exec_sql', { sql_query: sql });
// If RPC fails (likely), try direct query via pg (not available) or just hope RPC works?
// Wait, standard Supabase doesn't expose exec_sql by default unless I added it?
// I did NOT add exec_sql RPC.
// I must use the 'postgres' library or just use the dashboard?
// But I have `apply_schema_update.js` pattern from earlier conversations?
// No, I'll use the "run SQL via file" if I had a tool.
// Actually, `supabaseAdmin` can't run raw SQL unless there's an RPC.
// ALTERNATIVE: Use the `pg` library if installed?
// Let's check package.json
} catch (err) {
console.error(err);
}
}
// Checking package.json...