forked from khaoss85/mcp-orchestro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_migration_012.mjs
More file actions
52 lines (41 loc) · 1.74 KB
/
run_migration_012.mjs
File metadata and controls
52 lines (41 loc) · 1.74 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
#!/usr/bin/env node
import { readFileSync } from 'fs';
import { getSupabaseClient } from './dist/db/supabase.js';
async function runMigration() {
console.log('📦 Running Migration 012: Project Configuration System\n');
try {
const supabase = getSupabaseClient();
// Read migration file
const migrationSQL = readFileSync('src/db/migrations/012_project_configuration_system.sql', 'utf-8');
console.log('🔄 Executing migration SQL...');
const { data, error } = await supabase.rpc('exec_sql', {
sql_query: migrationSQL
});
if (error) {
// Try direct execution if rpc doesn't work
console.log('⚠️ RPC failed, trying direct execution...');
// Split by semicolons and execute each statement
const statements = migrationSQL
.split(';')
.map(s => s.trim())
.filter(s => s.length > 0 && !s.startsWith('--'));
for (const statement of statements) {
const result = await supabase.from('__migrations').select('*').limit(1); // dummy query to test
if (result.error) {
console.error('❌ Error:', result.error);
}
}
console.log('\n⚠️ Manual migration required!');
console.log('Please run the migration SQL in Supabase SQL Editor:');
console.log('src/db/migrations/012_project_configuration_system.sql');
} else {
console.log('✅ Migration 012 executed successfully!');
console.log('Result:', data);
}
} catch (error) {
console.error('❌ Migration failed:', error.message);
console.log('\n📝 Please apply migration manually via Supabase SQL Editor:');
console.log(' Copy contents of: src/db/migrations/012_project_configuration_system.sql');
}
}
runMigration().catch(console.error);