Skip to main content
Glama
northernvariables

FedMCP - Federal Parliamentary Information

create-all-missing-profiles.js2.38 kB
/** * Create profiles for all users missing them * Run with: NEXT_PUBLIC_SUPABASE_URL=... SUPABASE_SERVICE_ROLE_KEY=... node scripts/create-all-missing-profiles.js */ const { createClient } = require('@supabase/supabase-js'); const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL; const supabaseKey = process.env.SUPABASE_SERVICE_ROLE_KEY; if (!supabaseUrl || !supabaseKey) { console.error('Missing environment variables'); console.error('Please set NEXT_PUBLIC_SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY'); process.exit(1); } const supabase = createClient(supabaseUrl, supabaseKey, { auth: { autoRefreshToken: false, persistSession: false } }); async function createAllMissingProfiles() { console.log('Fetching all auth users...'); const { data: { users }, error: usersError } = await supabase.auth.admin.listUsers(); if (usersError) { console.error('Error fetching users:', usersError); return; } console.log(`Found ${users.length} users in auth.users\n`); let created = 0; let skipped = 0; for (const user of users) { // Check if profile exists const { data: profile } = await supabase .from('user_profiles') .select('id') .eq('id', user.id) .single(); if (profile) { skipped++; continue; } // Create profile console.log(`Creating profile for ${user.email}...`); const { error: createError } = await supabase .from('user_profiles') .insert({ id: user.id, email: user.email, full_name: user.user_metadata?.full_name || user.email, subscription_tier: 'FREE', monthly_usage: 0, usage_reset_date: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(), created_at: user.created_at, updated_at: new Date().toISOString() }); if (createError) { console.error(` ✗ Error creating profile: ${createError.message}`); } else { console.log(` ✓ Profile created`); created++; } } console.log(`\nSummary:`); console.log(` Created: ${created}`); console.log(` Skipped (already exists): ${skipped}`); console.log(` Total: ${users.length}`); } createAllMissingProfiles() .then(() => { console.log('\nDone!'); process.exit(0); }) .catch((error) => { console.error('Error:', error); process.exit(1); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/northernvariables/FedMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server