// Script to dump the blog_posts table schema from Supabase import { config } from 'dotenv'; import { createClient } from '@supabase/supabase-js'; // Load environment variables config({ path: '.env.local' }); // Create Supabase client const supabase = createClient( process.env.NEXT_PUBLIC_SUPABASE_URL, process.env.SUPABASE_SERVICE_ROLE_KEY ); async function dumpTableSchema() { try { console.log('Dumping blog_posts table schema...'); // Get sample records to see the actual data structure const { data: sampleData, error: sampleError } = await supabase .from('blog_posts') .select('*') .limit(1); if (sampleError) { console.error('Error fetching sample data:', sampleError); return; } console.log('Sample blog post data:'); console.log(JSON.stringify(sampleData, null, 2)); // List available columns if (sampleData && sampleData.length > 0) { console.log('Available columns in the first record:'); console.log(Object.keys(sampleData[0])); // Check if the tags column exists const hasTagsColumn = 'tags' in sampleData[0]; console.log(`Tags column exists: ${hasTagsColumn}`); } else { console.log('No blog posts found in the database.'); } } catch (error) { console.error('Unexpected error:', error); } } dumpTableSchema();