-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.js
More file actions
108 lines (88 loc) · 3.44 KB
/
Copy pathdebug.js
File metadata and controls
108 lines (88 loc) · 3.44 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
require('dotenv').config();
const { createClient } = require('@supabase/supabase-js');
// Çevre değişkenlerini kontrol et
console.log('Çevre değişkenleri kontrol ediliyor...');
console.log('SUPABASE_URL:', process.env.SUPABASE_URL ? 'Mevcut' : 'Bulunamadı');
console.log('SUPABASE_KEY:', process.env.SUPABASE_KEY ? 'Mevcut (gizli)' : 'Bulunamadı');
console.log('TOKEN:', process.env.TOKEN ? 'Mevcut (gizli)' : 'Bulunamadı');
// Supabase bağlantısını test et
async function testSupabaseConnection() {
console.log('\nSupabase bağlantısı test ediliyor...');
try {
const supabaseUrl = process.env.SUPABASE_URL;
const supabaseKey = process.env.SUPABASE_KEY;
if (!supabaseUrl || !supabaseKey) {
console.error('HATA: SUPABASE_URL veya SUPABASE_KEY çevre değişkenleri bulunamadı!');
return false;
}
console.log('Supabase URL:', supabaseUrl);
const supabase = createClient(supabaseUrl, supabaseKey);
// Bağlantıyı test et
const { data, error } = await supabase.from('partner_system').select('*').limit(1);
if (error) {
if (error.code === '42P01') {
console.log('Tablolar henüz oluşturulmamış. migrate.js çalıştırılmalı.');
return false;
} else {
console.error('Supabase bağlantı hatası:', error);
return false;
}
} else {
console.log('Supabase bağlantısı başarılı!');
return true;
}
} catch (err) {
console.error('Supabase bağlantı testi sırasında hata:', err);
return false;
}
}
// Tabloları kontrol et
async function checkTables() {
console.log('\nTablolar kontrol ediliyor...');
try {
const supabaseUrl = process.env.SUPABASE_URL;
const supabaseKey = process.env.SUPABASE_KEY;
if (!supabaseUrl || !supabaseKey) {
console.error('HATA: SUPABASE_URL veya SUPABASE_KEY çevre değişkenleri bulunamadı!');
return;
}
const supabase = createClient(supabaseUrl, supabaseKey);
const tables = [
'partner_system',
'partner_text',
'partner_count',
'partner_logs',
'partner_timestamps',
'banned_guilds',
'partner_toggle',
'guild_data'
];
for (const table of tables) {
try {
const { error } = await supabase.from(table).select('*').limit(1);
if (error && error.code === '42P01') {
console.log(`❌ ${table} tablosu bulunamadı.`);
} else {
console.log(`✅ ${table} tablosu mevcut.`);
}
} catch (err) {
console.error(`${table} tablosu kontrol edilirken hata:`, err);
}
}
} catch (err) {
console.error('Tablo kontrolü sırasında hata:', err);
}
}
// Ana fonksiyon
async function main() {
console.log('Hata ayıklama başlatılıyor...');
const connectionSuccess = await testSupabaseConnection();
if (connectionSuccess) {
await checkTables();
}
console.log('\nHata ayıklama tamamlandı.');
}
// Programı çalıştır
main().catch(error => {
console.error('Program hatası:', error);
});