-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfix-inconsistent-source.js
More file actions
73 lines (60 loc) · 2.12 KB
/
fix-inconsistent-source.js
File metadata and controls
73 lines (60 loc) · 2.12 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
// Скрипт для удаления inconsistent source из Hasura
// Запуск: node fix-inconsistent-source.js
require('dotenv').config();
const axios = require('axios');
const HASURA_URL = process.env.NEXT_PUBLIC_HASURA_GRAPHQL_URL || 'https://hasyx.hasura.app/v1';
const HASURA_SECRET = process.env.HASURA_ADMIN_SECRET;
if (!HASURA_SECRET) {
console.error('❌ HASURA_ADMIN_SECRET не установлен');
process.exit(1);
}
async function fixInconsistentSource() {
try {
console.log('🔍 Проверяю inconsistent metadata...');
// Получить inconsistent metadata
const response = await axios.post(
`${HASURA_URL}/metadata`,
{
type: 'get_inconsistent_metadata',
args: {}
},
{
headers: {
'x-hasura-admin-secret': HASURA_SECRET
}
}
);
const inconsistent = response.data;
if (!inconsistent.inconsistent_objects || inconsistent.inconsistent_objects.length === 0) {
console.log('✅ Нет inconsistent объектов');
return;
}
console.log(`📋 Найдено ${inconsistent.inconsistent_objects.length} inconsistent объектов:`);
inconsistent.inconsistent_objects.forEach(obj => {
console.log(` - ${obj.type}: ${obj.name || obj.definition || 'unknown'}`);
if (obj.reason) {
console.log(` Причина: ${obj.reason}`);
}
});
// Удалить inconsistent metadata
console.log('\n🗑️ Удаляю inconsistent metadata...');
const dropResponse = await axios.post(
`${HASURA_URL}/metadata`,
{
type: 'drop_inconsistent_metadata',
args: {}
},
{
headers: {
'x-hasura-admin-secret': HASURA_SECRET
}
}
);
console.log('✅ Inconsistent metadata удален');
console.log('\n💡 Теперь можно подключить базу через Connection Parameters в Hasura Console');
} catch (error) {
console.error('❌ Ошибка:', error.response?.data || error.message);
process.exit(1);
}
}
fixInconsistentSource();