-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-supabase-table.js
More file actions
114 lines (100 loc) · 4.82 KB
/
Copy pathcreate-supabase-table.js
File metadata and controls
114 lines (100 loc) · 4.82 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<<<<<<< HEAD
const { createClient } = require('@supabase/supabase-js');
require('dotenv').config();
// Get Supabase credentials from environment variables
const supabaseUrl = process.env.SUPABASE_URL;
const supabaseKey = process.env.SUPABASE_KEY;
console.log('Creating users table in Supabase...');
// Create Supabase client
const supabase = createClient(supabaseUrl, supabaseKey);
// Function to create the users table
async function createUsersTable() {
try {
console.log('Connecting to Supabase...');
// Since we can't execute DDL statements directly through the JS client,
// we'll provide the SQL that needs to be executed in the Supabase dashboard
console.log('\n📋 PLEASE FOLLOW THESE STEPS TO CREATE THE TABLE:');
console.log('\n1. Go to your Supabase dashboard:');
console.log(' https://app.supabase.com/project/' + supabaseUrl.split('/')[3] + '/sql');
console.log('\n2. Click "New query"');
console.log('\n3. Copy and paste the following SQL:');
console.log('\n' + '='.repeat(50));
console.log('-- Create the users table for astrological analysis reports');
console.log('CREATE TABLE IF NOT EXISTS users (');
console.log(' id UUID DEFAULT gen_random_uuid() PRIMARY KEY,');
console.log(' first_name TEXT NOT NULL,');
console.log(' last_name TEXT NOT NULL,');
console.log(' birth_date DATE NOT NULL,');
console.log(' birth_time TIME NOT NULL,');
console.log(' birth_place TEXT NOT NULL,');
console.log(' face_image_path TEXT,');
console.log(' hand_image_path TEXT,');
console.log(' analysis_result JSONB,');
console.log(' created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()');
console.log(');');
console.log('');
console.log('-- Add indexes for better query performance');
console.log('CREATE INDEX IF NOT EXISTS idx_users_created_at ON users (created_at);');
console.log('CREATE INDEX IF NOT EXISTS idx_users_last_name ON users (last_name);');
console.log('');
console.log('-- Enable RLS (Row Level Security) if needed');
console.log('ALTER TABLE users ENABLE ROW LEVEL SECURITY;');
console.log('='.repeat(50));
console.log('\n4. Click "Run" to execute the query');
console.log('\n✅ Once you\'ve completed these steps, your table will be ready!');
} catch (error) {
console.error('❌ Error:', error.message);
process.exit(1);
}
}
=======
const { createClient } = require('@supabase/supabase-js');
require('dotenv').config();
// Get Supabase credentials from environment variables
const supabaseUrl = process.env.SUPABASE_URL;
const supabaseKey = process.env.SUPABASE_KEY;
console.log('Creating users table in Supabase...');
// Create Supabase client
const supabase = createClient(supabaseUrl, supabaseKey);
// Function to create the users table
async function createUsersTable() {
try {
console.log('Connecting to Supabase...');
// Since we can't execute DDL statements directly through the JS client,
// we'll provide the SQL that needs to be executed in the Supabase dashboard
console.log('\n📋 PLEASE FOLLOW THESE STEPS TO CREATE THE TABLE:');
console.log('\n1. Go to your Supabase dashboard:');
console.log(' https://app.supabase.com/project/' + supabaseUrl.split('/')[3] + '/sql');
console.log('\n2. Click "New query"');
console.log('\n3. Copy and paste the following SQL:');
console.log('\n' + '='.repeat(50));
console.log('-- Create the users table for astrological analysis reports');
console.log('CREATE TABLE IF NOT EXISTS users (');
console.log(' id UUID DEFAULT gen_random_uuid() PRIMARY KEY,');
console.log(' first_name TEXT NOT NULL,');
console.log(' last_name TEXT NOT NULL,');
console.log(' birth_date DATE NOT NULL,');
console.log(' birth_time TIME NOT NULL,');
console.log(' birth_place TEXT NOT NULL,');
console.log(' face_image_path TEXT,');
console.log(' hand_image_path TEXT,');
console.log(' analysis_result JSONB,');
console.log(' created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()');
console.log(');');
console.log('');
console.log('-- Add indexes for better query performance');
console.log('CREATE INDEX IF NOT EXISTS idx_users_created_at ON users (created_at);');
console.log('CREATE INDEX IF NOT EXISTS idx_users_last_name ON users (last_name);');
console.log('');
console.log('-- Enable RLS (Row Level Security) if needed');
console.log('ALTER TABLE users ENABLE ROW LEVEL SECURITY;');
console.log('='.repeat(50));
console.log('\n4. Click "Run" to execute the query');
console.log('\n✅ Once you\'ve completed these steps, your table will be ready!');
} catch (error) {
console.error('❌ Error:', error.message);
process.exit(1);
}
}
>>>>>>> 4939126ee5c953624a0df2c93b0c18153fd12173
createUsersTable();