feat: Feature 1.2 (NBA stats FastAPI service) + Feature 1.4 (database schema)
Feature 1.2: Python FastAPI microservice wrapping nba_api - GET /stats/season-avg, /stats/last-n, /stats/splits, /players/search - Redis caching (24hr/1hr/6hr/7day), 0.6s rate limiting, PRA derived stat - 27 Python tests passing Feature 1.4: Complete Supabase database schema - 6 tables: users, picks, scan_sessions, bets, outcomes, performance - RLS enabled on all tables with auth.uid() policies - 3 triggers: auto-create user, updated_at, scan count reset - 37 schema validation tests passing - Migration SQL ready, pending manual apply (WSL2 DNS blocker) Total: 92 tests (65 Node.js + 27 Python), all passing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
require('dotenv').config();
|
||||
const { createClient } = require('@supabase/supabase-js');
|
||||
|
||||
const supabase = createClient(
|
||||
process.env.SUPABASE_URL,
|
||||
process.env.SUPABASE_SERVICE_KEY
|
||||
);
|
||||
|
||||
const EXPECTED_TABLES = ['users', 'picks', 'scan_sessions', 'bets', 'outcomes', 'performance'];
|
||||
|
||||
async function verifySchema() {
|
||||
console.log('[BetonBLK] Verifying database schema...\n');
|
||||
|
||||
let allPassed = true;
|
||||
|
||||
// Check each table exists by querying it
|
||||
for (const table of EXPECTED_TABLES) {
|
||||
const { data, error } = await supabase.from(table).select('*').limit(0);
|
||||
if (error) {
|
||||
console.error(` FAIL: ${table} — ${error.message}`);
|
||||
allPassed = false;
|
||||
} else {
|
||||
console.log(` OK: ${table}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('');
|
||||
|
||||
// Test RLS: service role should be able to query all tables
|
||||
console.log('Testing service role access...');
|
||||
for (const table of EXPECTED_TABLES) {
|
||||
const { error } = await supabase.from(table).select('*').limit(1);
|
||||
if (error) {
|
||||
console.error(` FAIL: service role cannot access ${table} — ${error.message}`);
|
||||
allPassed = false;
|
||||
} else {
|
||||
console.log(` OK: service role can access ${table}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('');
|
||||
|
||||
if (allPassed) {
|
||||
console.log('ALL CHECKS PASSED. Schema is correctly applied.');
|
||||
} else {
|
||||
console.error('SOME CHECKS FAILED. Review errors above.');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
verifySchema().catch((err) => {
|
||||
console.error('Verification failed:', err.message);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user