Prerequisites
Before you begin, ensure you have:- A Supabase account
- A Supabase project created
- Your Supabase environment variables configured (see Environment variables)
Database schema
Wrkks requires ausers table to store user information and resume data.
Create the users table
Run this SQL in the Supabase SQL Editor:Open SQL Editor
Navigate to your Supabase project dashboard and go to SQL Editor in the left sidebar.
This schema automatically handles user synchronization with Clerk via the
clerk_user_id field.Table structure
Theusers table has the following columns:
Primary key, automatically generated UUID for each user.
Unique identifier from Clerk authentication. Used to link Supabase users with Clerk users.
Unique username for the user. Used in public profile URLs (e.g.,
wrkks.site/username).User’s email address, synced from Clerk.
Stores the complete resume data as JSON. Structure matches the
Resume interface from lib/types.ts:1.Can be null if the user hasn’t uploaded a resume yet.Timestamp when the user record was created.
Timestamp when the user record was last updated. Automatically updated via trigger.
Resume data structure
Theresume field stores a JSON object with the following structure:
This structure is defined in
lib/types.ts and is automatically populated by the AI parsing service.Row Level Security (RLS)
Row Level Security ensures users can only access their own data. Set up RLS policies to secure your database:Clerk and Supabase integration
Wrkks synchronizes Clerk users with Supabase automatically through theSyncUser component:
- When a user signs in with Clerk, the
SyncUsercomponent runs server-side - It checks if a user with the matching
clerk_user_idexists in Supabase - If not, it creates a new user record with:
clerk_user_idfrom Clerkusernamederived from emailemailfrom Clerkresumeset tonull
User synchronization happens automatically. You don’t need to manually create users in Supabase.
Testing your database
Verify your database is set up correctly:Test user creation
Sign up with a new account in your local or deployed app. Check the
users table in Supabase to verify a new record was created.Database queries
Here are some useful SQL queries for managing your database:Backup and maintenance
Automatic backups
Supabase automatically backs up your database daily. To configure backup retention:- Go to Settings → Database in your Supabase project
- Configure Point-in-Time Recovery (PITR) for production projects
- Set up backup alerts
Manual backup
To create a manual backup:Database migrations
For schema changes, use Supabase migrations:Troubleshooting
”relation public.users does not exist”
- Verify you ran the schema SQL in the correct database
- Check that you’re connected to the right Supabase project
- Ensure the SQL query executed without errors
Users not syncing from Clerk
- Check that Supabase environment variables are correct
- Verify the
clerk_user_idfield exists and is unique - Look for errors in your application logs during sign-in
- Ensure RLS policies allow insertion (checked in
components/SyncUser.tsx:21)
RLS policies blocking requests
- Verify your Clerk JWT tokens include the
subclaim - Check that the
auth.jwt()function works in your Supabase environment - Test policies with the Supabase policy editor
- Temporarily disable RLS to test if that’s the issue (don’t forget to re-enable)
Resume data not saving
- Verify the
resumecolumn type isjsonb, notjsonortext - Check that your JSON structure matches the
Resumeinterface - Look for JSON validation errors in application logs
- Ensure the JSON is valid (use
JSON.parse()to test)
Production considerations
Enable PITR
Enable Point-in-Time Recovery for production databases to allow restoration to any point in time.
Configure connection pooling
Use Supabase’s connection pooler (Supavisor) for serverless environments.
Next steps
Deployment overview
Deploy your application to production
Environment variables
Review all required environment variables