The error you're seeing means the PostgreSQL functions haven't been created yet. Follow these steps to fix it:
Option A: Use the step-by-step script (Recommended)
- Open Supabase SQL Editor
- Copy and paste the entire contents of
create-h1b-functions-step-by-step.sql - Click "Run" to execute all steps at once
Option B: Run the original migration
-
If you have Supabase CLI installed:
supabase db push
-
Or manually copy
supabase/migrations/20240125_create_h1b_statistics_functions.sqlinto Supabase SQL Editor
- Copy and paste
test-h1b-functions.sqlinto Supabase SQL Editor - Run the tests to verify everything works
- You should see results like:
{
"totalApplications": 10,
"averageSalary": 168500,
"certificationRate": 70.00,
"topEmployers": [
{"name": "Google LLC", "count": 1},
{"name": "Microsoft Corporation", "count": 1}
]
}Once the functions are created, you can use them in your React components:
import { H1BStatisticsComponent } from './components/h1b/H1BStatistics';
function App() {
return (
<div>
<H1BStatisticsComponent enableCache={true} />
</div>
);
}The step-by-step script will create a sample table with test data. If you have your own H1B data, make sure your table has these columns:
case_number(VARCHAR)case_status(VARCHAR)employer_name(VARCHAR)job_title(VARCHAR)wage_rate_of_pay_from(NUMERIC)wage_rate_of_pay_to(NUMERIC)received_date(DATE)worksite_state(VARCHAR)
Make sure you're running the SQL as a user with sufficient privileges. The functions include SECURITY DEFINER to run with elevated permissions.
- Check that your Supabase client is properly configured
- Verify the functions exist:
SELECT routine_name FROM information_schema.routines WHERE routine_name LIKE 'get_h1b%';
Run these in Supabase SQL Editor to verify everything works:
-- Check if functions exist
SELECT routine_name
FROM information_schema.routines
WHERE routine_name LIKE 'get_h1b%';
-- Test basic function
SELECT get_h1b_statistics();
-- Test with filters
SELECT get_h1b_statistics('Google', 'CERTIFIED');The step-by-step script includes sample data from major tech companies:
- Google, Microsoft, Apple, Amazon, Meta
- Various job titles and salary ranges
- Different application statuses
This gives you immediate data to test with before loading your real H1B dataset.
- ✅ Create functions using
create-h1b-functions-step-by-step.sql - ✅ Test functions using
test-h1b-functions.sql - ✅ Use
H1BStatisticsComponentin your React app - 📊 Load your real H1B data (optional)
- 🎨 Customize the dashboard components
The system will work immediately with the sample data, then you can replace it with your actual H1B dataset when ready!