Add schema cache fallback for service account JSON
- Add fallback RPC method when PostgREST schema cache fails - Save service account JSON separately via raw SQL - Show warning message if manual save needed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -116,7 +116,40 @@ export function IntegrasiTab() {
|
|||||||
.update(platformPayload)
|
.update(platformPayload)
|
||||||
.eq('id', settings.id);
|
.eq('id', settings.id);
|
||||||
|
|
||||||
if (platformError) throw platformError;
|
if (platformError) {
|
||||||
|
// If schema cache error, try saving service account JSON separately via raw SQL
|
||||||
|
if (platformError.code === 'PGRST204' && settings.integration_google_service_account_json) {
|
||||||
|
console.log('Schema cache error, using fallback RPC method');
|
||||||
|
const { error: rpcError } = await supabase.rpc('exec_sql', {
|
||||||
|
sql: `UPDATE platform_settings SET google_service_account_json = '${settings.integration_google_service_account_json.replace(/'/g, "''")}'::jsonb WHERE id = '${settings.id}'`
|
||||||
|
});
|
||||||
|
|
||||||
|
if (rpcError) {
|
||||||
|
// Save other fields without the problematic column
|
||||||
|
const { error: retryError } = await supabase
|
||||||
|
.from('platform_settings')
|
||||||
|
.update({
|
||||||
|
integration_n8n_base_url: settings.integration_n8n_base_url,
|
||||||
|
integration_whatsapp_number: settings.integration_whatsapp_number,
|
||||||
|
integration_whatsapp_url: settings.integration_whatsapp_url,
|
||||||
|
integration_google_calendar_id: settings.integration_google_calendar_id,
|
||||||
|
integration_email_provider: settings.integration_email_provider,
|
||||||
|
integration_email_api_base_url: settings.integration_email_api_base_url,
|
||||||
|
integration_privacy_url: settings.integration_privacy_url,
|
||||||
|
integration_terms_url: settings.integration_terms_url,
|
||||||
|
integration_n8n_test_mode: settings.integration_n8n_test_mode,
|
||||||
|
})
|
||||||
|
.eq('id', settings.id);
|
||||||
|
|
||||||
|
if (retryError) throw retryError;
|
||||||
|
toast({ title: 'Peringatan', description: 'Pengaturan disimpan tapi Service Account JSON perlu disimpan manual. Hubungi admin.' });
|
||||||
|
} else {
|
||||||
|
toast({ title: 'Berhasil', description: 'Service Account JSON disimpan via RPC' });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw platformError;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save email provider settings to notification_settings
|
// Save email provider settings to notification_settings
|
||||||
|
|||||||
10
verify-column.sql
Normal file
10
verify-column.sql
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
-- Check if column exists in database
|
||||||
|
SELECT
|
||||||
|
column_name,
|
||||||
|
data_type,
|
||||||
|
is_nullable,
|
||||||
|
column_default
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_schema = 'public'
|
||||||
|
AND table_name = 'platform_settings'
|
||||||
|
ORDER BY ordinal_position;
|
||||||
Reference in New Issue
Block a user