Files
orangecat/scripts/check-database-data.js
Your NameandClaude Opus 4.5 295e39eddf fix: update scripts to use environment variables
Scripts now read from .env.local using dotenv instead of
having hardcoded values or placeholders.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 13:15:56 +01:00

77 lines
2.3 KiB
JavaScript

#!/usr/bin/env node
/**
* Script to check database contents and add sample data if needed
*/
const { createClient } = require('@supabase/supabase-js');
require('dotenv').config({ path: '.env.local' });
// Get environment variables
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
if (!supabaseUrl || !supabaseKey) {
console.error('Missing NEXT_PUBLIC_SUPABASE_URL or NEXT_PUBLIC_SUPABASE_ANON_KEY');
process.exit(1);
}
const supabase = createClient(supabaseUrl, supabaseKey);
async function checkDatabase() {
console.log('🔍 Checking database contents...\n');
try {
// Check profiles
const { data: profiles, error: profilesError } = await supabase
.from('profiles')
.select('id, username, name, created_at')
.limit(10);
if (profilesError) {
console.error('❌ Error fetching profiles:', profilesError.message);
} else {
console.log(`👥 Profiles found: ${profiles.length}`);
profiles.forEach(profile => {
console.log(` - ${profile.username || 'No username'} (${profile.name || 'No name'}) - ${profile.created_at}`);
});
}
// Check projects
const { data: projects, error: projectsError } = await supabase
.from('projects')
.select('id, title, status, created_at')
.limit(10);
if (projectsError) {
console.error('❌ Error fetching projects:', projectsError.message);
} else {
console.log(`\n📋 Projects found: ${projects.length}`);
projects.forEach(project => {
console.log(` - "${project.title}" (${project.status}) - ${project.created_at}`);
});
}
// Check active projects specifically
const { data: activeProjects, error: activeProjectsError } = await supabase
.from('projects')
.select('id, title, status, created_at')
.eq('status', 'active')
.limit(10);
if (activeProjectsError) {
console.error('❌ Error fetching active projects:', activeProjectsError.message);
} else {
console.log(`\n✅ Active projects: ${activeProjects.length}`);
}
console.log('\n✨ Database check complete!');
} catch (error) {
console.error('❌ Database check failed:', error);
}
}
// Run the check
checkDatabase();