The error "relation "public.user_preferences" does not exist" means that your Supabase database doesn't have the required tables yet. You need to apply the database schema first.
- Open your browser and go to supabase.com
- Sign in to your account
- Select your ReBin Pro project
- In your Supabase dashboard, click on "SQL Editor" in the left sidebar
- Click "New Query" to create a new SQL query
- Copy the entire contents of
database/schema.sqlfile - Paste it into the SQL Editor
- Click "Run" to execute the schema
- In the same SQL Editor, create another new query
- Copy the entire contents of
database/user_trigger.sqlfile - Paste it into the SQL Editor
- Click "Run" to execute the triggers
- In your Supabase dashboard, click on "Table Editor" in the left sidebar
- You should now see these tables:
- ✅
users - ✅
user_preferences - ✅
sort_events - ✅
policies - ✅
achievements - ✅
challenges - ✅
challenge_participants - ✅
user_sessions - ✅
analytics_events - ✅
feedback - ✅
leaderboard
- ✅
If you prefer to use a script, you can also run:
# Make sure you're in the project root
cd /Users/peguero/Rebin-1
# Run the database setup script
python3 database/run_migration.pyAfter applying the schema:
-
Restart your development server:
cd frontend npm run dev -
Test registration:
- Go to http://localhost:5173/register
- Create a new account
- Check your Supabase dashboard → Table Editor →
userstable - You should see the new user record
The schema.sql file creates:
users- User profiles and informationuser_preferences- User settings and preferencessort_events- Waste sorting events and decisionspolicies- Local recycling policies by ZIP code
achievements- User achievements and badgeschallenges- Community challengeschallenge_participants- User participation in challengesleaderboard- User rankings and statistics
user_sessions- User session trackinganalytics_events- Detailed analyticsfeedback- User feedback on sorting decisions
- Automatic timestamp updates
- Leaderboard calculations
- Achievement checking
- User profile synchronization
- Make sure you're using the correct Supabase project
- Check that you have admin access to the project
- Verify your Supabase project is fully initialized
- Check the SQL Editor for any error messages
- Make sure you copied the entire
schema.sqlcontent - Try running the schema in smaller chunks if it's too large
- This means some tables already exist
- You can safely ignore these errors
- The schema will only create tables that don't exist
The fix is working when:
- ✅ All tables appear in Supabase Table Editor
- ✅ No errors in SQL Editor when running the schema
- ✅ User registration creates records in the
userstable - ✅ No more "relation does not exist" errors
database/schema.sql- Main database schema (apply this first)database/user_trigger.sql- User profile triggers (apply this second)
Once you apply the database schema, the authentication system will work perfectly and users will be properly stored in your Supabase database! 🎉