green-guard-api / scripts /verify-map.js
Shardul Chogale
chore: update default admin email address in seed script
ac2662d
Raw History Blame Contribute Delete
1.79 kB
/**
* Map Verification Script
* Inserts a test "NGO Plantation" post with geospatial data.
*/
require('dotenv').config();
const { createClient } = require('@supabase/supabase-js');
const supabase = createClient(
process.env.SUPABASE_URL,
process.env.SUPABASE_SERVICE_ROLE_KEY
);
async function verifyMapData() {
console.log('๐Ÿ—บ๏ธ Seeding a test plantation post for map verification...');
// 1. Get Admin User
const adminEmail = process.env.ADMIN_EMAIL || 'admin@greenguard.in';
const { data: admin } = await supabase.from('profiles').select('id').eq('email', adminEmail).single();
if (!admin) {
console.error('โŒ Admin user not found. Please run seed-admin.js first.');
return;
}
// 2. Insert Plantation Post (Mumbai)
const testPost = {
author_id: admin.id,
content: 'Special NGO Plantation Event! We just planted 50 saplings at Sanjay Gandhi National Park. ๐ŸŒณ',
post_type: 'plantation',
latitude: 19.2212,
longitude: 72.9113,
location: 'POINT(72.9113 19.2212)',
address: 'Sanjay Gandhi National Park, Mumbai',
image_urls: ['https://images.unsplash.com/photo-1542601906990-b4d3fb778b09?auto=format&fit=crop&q=80&w=800']
};
const { data, error } = await supabase.from('posts').insert(testPost).select().single();
if (error) {
console.error('โŒ Failed to insert test post:', error.message);
if (error.message.includes('column "post_type" does not exist')) {
console.error('๐Ÿ‘‰ This means the SQL migration was NOT successful.');
}
} else {
console.log('โœ… Success! Test plantation post created with ID:', data.id);
console.log('๐Ÿ“ Location:', testPost.address);
console.log('\n๐Ÿš€ Now refresh your /map page to see the new indigo marker!');
}
}
verifyMapData();