Files
orangecat/scripts/db-audit.mjs
Your Name 38cc4669d8 chore: comprehensive codebase cleanup and organization
- Move 100+ files from root to proper directories
  - Migration scripts → scripts/db/
  - SQL files → supabase/sql/archive/
  - Test/debug scripts → scripts/test/
  - Documentation → docs/archive/ (organized by category)
  - Shell scripts → scripts/ (organized by category)

- Fix test organization
  - Remove nested tests/unit/tests/unit/ structure
  - Consolidate test files to proper locations

- Update documentation references
  - Update migration script paths in workflow docs
  - Update scripts/README.md with moved file notes

- Delete placeholder files
  - Remove empty placeholder.ipynb

- Result: Root directory now contains only essential config files
- Result: Professional, organized codebase structure
- Result: All files in proper locations per project standards

See docs/CLEANUP_COMPLETE.md for full details.
2025-12-21 22:57:54 +01:00

55 lines
1.4 KiB
JavaScript

#!/usr/bin/env node
import { createClient } from '@supabase/supabase-js';
const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
const anon = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
const service = process.env.SUPABASE_SERVICE_ROLE_KEY || anon;
if (!url || !service) {
console.error('Set NEXT_PUBLIC_SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY (or ANON for read-only).');
process.exit(1);
}
const supabase = createClient(url, service, { auth: { persistSession: false } });
const tables = [
'profiles',
'projects',
'project_media',
'wallets',
'user_products',
'user_services',
'assets',
'conversations',
'conversation_participants',
'messages',
'follows',
'organizations',
'organization_members',
];
console.log('Auditing Supabase schema...');
for (const table of tables) {
const { data, error } = await supabase.from(table).select('count').limit(1);
if (error) {
console.log(`- ${table}: MISSING or no access (${error.code || error.message})`);
} else {
console.log(`- ${table}: OK`);
}
}
// Check RPC function optionally used by wallets
try {
const { data, error } = await supabase.rpc('get_entity_wallets', {
p_entity_type: 'profile',
p_entity_id: '00000000-0000-0000-0000-000000000000',
});
if (error) throw error;
console.log('- rpc:get_entity_wallets: OK');
} catch (e) {
console.log('- rpc:get_entity_wallets: MISSING or no access');
}
console.log('Audit complete.');