This guide will help you set up your Supabase database for the CodeArena project.
- Visit Supabase Dashboard
- Click "New Project"
- Choose your organization (or create one)
- Fill in project details:
- Name: CodeArena (or your preferred name)
- Database Password: Choose a strong password
- Region: Select the closest region to your users
- Click "Create new project"
- Wait 1-2 minutes for provisioning
- In your project dashboard, go to Settings (gear icon)
- Click API in the left sidebar
- Copy these values:
- Project URL (looks like:
https://xxxxx.supabase.co) - Project API keys → anon/public key
- Project URL (looks like:
-
In your Supabase dashboard, go to SQL Editor
-
Click "New Query"
-
Open each migration file from
supabase/migrations/folder -
Copy and paste the content in this order:
First Migration:
20250122044859_empty_tooth.sql- Creates profiles and friend_requests tables
Second Migration:
20250122050051_dawn_lantern.sql- Adds additional tables and relationships
Third Migration:
20250122050650_bronze_moon.sql- Sets up projects and tournaments tables
Fourth Migration:
20250123120557_wooden_field.sql- Final schema updates
-
Click "Run" for each migration
-
Verify no errors appear
If you have Supabase CLI installed:
# Install Supabase CLI if not installed
npm install -g supabase
# Login to Supabase
npx supabase login
# Link your project
npx supabase link --project-ref your-project-ref
# Push migrations
npx supabase db push-
Copy
.env.exampleto.env:cp .env.example .env
-
Edit
.envand add your credentials:VITE_SUPABASE_URL=https://xxxxx.supabase.co VITE_SUPABASE_ANON_KEY=your-anon-key-here
Stores user profile information
id: UUID (references auth.users)username: Unique usernamecreated_at: Timestampupdated_at: Timestamp
Manages friend connections
id: UUIDfrom_user: User sending requestto_user: User receiving requeststatus: pending/accepted/rejectedcreated_at: Timestamp
User project showcases
- Project details and metadata
- Associated with user profiles
Competitive coding events
- Tournament information
- Participant tracking
All tables have Row Level Security (RLS) enabled with policies:
- Users can read all profiles
- Users can manage their own data
- Proper authentication required
- Solution: You haven't run the migrations yet. Follow Step 3 above.
- Solution: Check that you copied the correct anon key from Supabase dashboard
- Make sure you're using the anon/public key, not the service_role key
- Solution:
- Check if your Supabase project is active (not paused)
- Verify the Project URL is correct in
.env - Check your internet connection
If your Supabase project was paused due to inactivity:
-
For Free Tier: Projects pause after 7 days of inactivity
- Click "Restore" or "Unpause" in the dashboard
- If restore fails, create a new project and run migrations
-
Data Migration (if needed):
# Export from old project npx supabase db dump > backup.sql # Import to new project npx supabase db reset psql your-new-connection-string < backup.sql
Run this query in SQL Editor to verify tables exist:
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public';You should see: profiles, friend_requests, projects, tournaments, etc.
After database setup:
- ✅ Start your development server:
npm run dev - ✅ Test authentication by signing up
- ✅ Verify data is being stored in Supabase dashboard
- ✅ Ready to deploy!
Need help? Check the main README.md or open an issue!