Database Setup

Set up Supabase PostgreSQL and run migrations.

Database Setup

PacBoiler uses Supabase (PostgreSQL) as the database. We use SQL migrations to manage the schema.

1. Access SQL Editor

  1. Go to your Supabase project dashboard.
  2. Click on the SQL Editor icon in the left sidebar.

2. Run Migrations

You need to run the migration files included in the supabase/migrations folder of this project in order.

Migration 1: Initial Schema

Copy the contents of supabase/migrations/001_initial_schema.sql and paste it into the SQL Editor. Click Run.

This creates the core infrastructure:

  • profiles table (linked to auth.users)
  • subscriptions table (LemonSqueezy integration)
  • webhook_events table (idempotency tracking)
  • Core functions: handle_new_user, handle_updated_at, is_admin, is_super_admin
  • delete_own_account function for secure user data removal
  • RLS policies and performance indexes

Migration 2: RBAC Policies

Copy the contents of supabase/migrations/002_rbac.sql and paste it into the SQL Editor. Click Run.

This adds:

  • Admin-specific security policies for profiles and subscriptions
  • Granular access control for super_admin roles

Migration 3: Waitlist

Copy the contents of supabase/migrations/003_waitlist.sql and paste it into the SQL Editor. Click Run.

This adds:

  • waitlist table for pre-launch signups
  • waitlist_conversions table to track conversion metrics
  • Waitlist management policies and stats functions

Migration 4: Notifications

Copy the contents of supabase/migrations/004_notifications.sql and paste it into the SQL Editor. Click Run.

This adds:

  • notifications table for in-app alerts
  • Helper functions for creating and managing notifications
  • Real-time notification tracking

3. Verify Tables

Go to the Table Editor (spreadsheet icon). You should see:

  • profiles
  • subscriptions
  • webhook_events
  • waitlist
  • waitlist_conversions
  • notifications

4. Promote First Admin

To access the Admin Panel, you need to make yourself a super_admin.

  1. Sign up for an account in your app (http://localhost:3000/signup).
  2. Go back to the SQL Editor in Supabase.
  3. Run the following query (replace with your email):
UPDATE public.profiles
SET role = 'super_admin'
WHERE email = 'your@email.com';

Next Steps

Now that the database is ready, let's set up payments.

Step 3: Payments Setup