Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/aluxey/E-Commerce/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you through setting up your Supabase project, including database creation, SQL migrations, and storage configuration.

Prerequisites

  • A Supabase account
  • Access to the SQL Editor in your Supabase dashboard
  • The SQL files from the Database/ directory

Create a New Project

1

Create Supabase Project

  1. Go to Supabase Dashboard
  2. Click New Project
  3. Choose your organization
  4. Enter project details:
    • Name: sabbels-handmade (or your preferred name)
    • Database Password: Choose a strong password
    • Region: Select the closest region to your users
  5. Click Create new project
Save your database password securely. You’ll need it for direct database connections.
2

Wait for Provisioning

Your project will take 1-2 minutes to provision. Once ready, you’ll see the project dashboard.

Run Database Migrations

Execute the SQL scripts in the following order to set up your database schema.
1

Navigate to SQL Editor

In your Supabase dashboard, click SQL Editor in the left sidebar.
2

Run Database Structure

  1. Click New Query
  2. Copy the contents of Database/BDD_struct.sql
  3. Paste into the SQL Editor
  4. Click Run
This creates all tables:
  • categories - Product categories
  • colors - Available colors for items
  • items - Main product table
  • item_variants - Size/color variants with stock
  • item_images - Product image gallery
  • item_colors - Available colors per item
  • item_ratings - Customer reviews
  • orders - Order records
  • order_items - Order line items
  • payments - Payment tracking
  • users - Customer accounts
  • customer_photos - Customer photo wall
  • stripe_events - Webhook event tracking
3

Apply Row Level Security

  1. Create a new query
  2. Copy the contents of Database/RLS.sql
  3. Paste and click Run
Run this query as Owner (use the “Run as Owner” option in the SQL Editor). This ensures RLS policies are created with the correct permissions.
This configures:
  • Public read access for products, colors, and categories
  • Admin-only write access for products
  • User-specific access to orders
  • Storage policies for product images
4

Seed Initial Data (Optional)

If you have a Database/SEED.sql file:
  1. Create a new query
  2. Copy the contents of Database/SEED.sql
  3. Paste and click Run
This populates:
  • Initial categories
  • Color palette
  • Sample products (if included)
5

Apply Migrations

Run migration files in chronological order from Database/migrations/:
-- Run each migration file in order by date:
-- 20251222_insert_categories.sql
-- 20251222_insert_colors.sql
-- 20251222_create_item_with_colors_rpc.sql
-- ... and so on
Only run migrations that are newer than your initial setup. Some migrations may already be included in BDD_struct.sql.

Configure Storage

Set up storage buckets for product images and customer photos.
1

Create Storage Bucket

  1. Go to Storage in the Supabase dashboard
  2. Click New bucket
  3. Configure the bucket:
    • Name: product-images
    • Public bucket: ✓ Enabled
    • File size limit: 10 MB
    • Allowed MIME types: image/*
  4. Click Create bucket
2

Verify Storage Policies

The RLS script already created storage policies. Verify them:
  1. Go to Storage > Policies
  2. Check for product-images bucket:
    • ✓ Public read access
    • ✓ Admin-only write access (insert, update, delete)

Get API Credentials

You’ll need these values for your environment variables.
1

Find Project URL

  1. Go to Project Settings > API
  2. Copy the Project URL
Example: https://abcdefghijklm.supabase.co
2

Get Anonymous Key

In the same API settings page:
  1. Find Project API keys
  2. Copy the anon public key
Use the anon key for client-side code. Never expose the service_role key in your frontend.
3

Get Service Role Key (API Server)

For your backend API server:
  1. In Project API keys, copy the service_role secret key
Keep this key secret! Only use it server-side in your API. It bypasses Row Level Security.

Create Admin User

Create your first admin account to access the admin panel.
1

Sign Up Through Your App

  1. Deploy or run your application locally
  2. Navigate to the sign-up page
  3. Create an account with your email
2

Promote to Admin

  1. Go to Supabase SQL Editor
  2. Run this query (replace with your email):
UPDATE public.users 
SET role = 'admin' 
WHERE email = 'your-email@example.com';
  1. Click Run
3

Verify Admin Access

  1. Log out and log back in to your application
  2. You should now see admin features in the navigation

Reset Database (Development)

If you need to reset your database during development:
This will permanently delete all data. Only use in development!
1

Run Reset Script

  1. Go to SQL Editor
  2. Copy contents of Database/reset_supabase.sql
  3. Paste and click Run
2

Rebuild Schema

After reset, re-run the setup:
  1. BDD_struct.sql - Database structure
  2. RLS.sql - Security policies
  3. SEED.sql - Initial data (optional)

Next Steps

Now that Supabase is configured:

Troubleshooting

”relation already exists” Error

If you see this error when running migrations:
  1. Check if the table already exists
  2. Drop the table if needed: DROP TABLE IF EXISTS table_name CASCADE;
  3. Re-run the migration

RLS Policies Not Working

If users can’t access data:
  1. Verify RLS is enabled: Go to Database > Tables > Check RLS enabled
  2. Check policies in Authentication > Policies
  3. Ensure the is_admin() function exists

Storage Upload Fails

If image uploads fail:
  1. Verify bucket exists and is public
  2. Check storage policies in Storage > Policies
  3. Verify file size is under 10MB
  4. Ensure MIME type is image/*

Build docs developers (and LLMs) love