-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit-supabase.js
More file actions
36 lines (29 loc) · 1.11 KB
/
init-supabase.js
File metadata and controls
36 lines (29 loc) · 1.11 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
// Script to initialize Supabase tables
import { supabase } from './server/supabaseClient';
import { randomUUID } from 'crypto';
async function initSupabaseTables() {
console.log('Initializing Supabase tables...');
try {
// Check if replies table exists by attempting to query it
const { data, error } = await supabase
.from('replies')
.select('id')
.limit(1);
if (error && error.code === '42P01') {
// Table doesn't exist, create it
console.log('Replies table does not exist. Please run the SQL migration manually or use drizzle-kit to create tables.');
console.log('You can run: npx drizzle-kit push');
return;
}
if (error) {
console.error('Error checking replies table:', error);
return;
}
console.log('Supabase tables are ready!');
console.log('Found existing replies table with data structure.');
} catch (error) {
console.error('Error initializing Supabase tables:', error);
}
}
// Run the initialization
initSupabaseTables();