ignitionstack.pro v1.0 is out! Read the announcement →
Skip to Content

Supabase Setup

This guide explains how to configure Supabase in the ignitionstack.pro project.

Quick Setup

1. Get Supabase Credentials

Option A: Use Existing Project

If you already have credentials:

# .env NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... SUPABASE_SERVICE_ROLE_KEY=your-service-role-key

Option B: Create New Project

  1. Go to supabase.com 

  2. Click “Start your project”

  3. Sign in (GitHub, Google, etc.)

  4. Click “New Project”

  5. Choose organization and region

  6. Configure:

    • Name: ignitionstack (or your preferred name)
    • Database Password: Strong password (save securely)
    • Region: Choose nearest (e.g., South America (Sao Paulo))
    • Pricing Plan: Free (for development)
  7. Wait ~2 minutes to provision

2. Copy Credentials

In the project dashboard:

  1. Go to SettingsAPI
  2. Copy the following:
# Project URL NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co # anon (public) key - can be exposed on client NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... # service_role key - NEVER expose on client! SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

3. Configure Environment Variables

Create/update .env file:

# Supabase Configuration NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key SUPABASE_SERVICE_ROLE_KEY=your-service-role-key

Important:

4. Install Dependencies

npm install

Creating Schema (Migrations)

Option 1: Via Dashboard

  1. Access SQL Editor in the dashboard
  2. Paste your SQL query:
-- Create posts table create table posts ( id uuid default gen_random_uuid() primary key, created_at timestamp with time zone default timezone('utc'::text, now()) not null, title text not null, slug text unique not null, content text, published boolean default false, author_id uuid references auth.users(id) on delete cascade ); -- Create indexes create index posts_slug_idx on posts(slug); create index posts_author_id_idx on posts(author_id); -- Enable Row Level Security alter table posts enable row level security; -- Policy: Anyone can read published posts create policy "Published posts are public" on posts for select using (published = true); -- Policy: Only author can update/delete their posts create policy "Authors can manage their posts" on posts for all using (auth.uid() = author_id);

Running the ignitionstack.pro SQL scripts in the Dashboard

The repository already ships with validated SQL that you can paste directly into the Supabase dashboard. You decide whether to run everything in a single shot or execute smaller slices table by table.

Option A: Run everything at once

  1. Open SQL Editor → New query in the Supabase dashboard.
  2. Copy the contents of supabase/migrations/implementation-full/schema.sql and paste them into the editor.
  3. Click Run. The file already includes extensions, tables, policies, functions, triggers, and helper data; executing it once will recreate the full schema.

You can do the same for supabase/migrations/implementation-full/seed.sql (optional demo/admin data) and supabase/migrations/implementation-full/rollback.sql (tears everything down).

Option B: Run smaller scripts sequentially

If you prefer to apply changes gradually or debug specific parts, use the split folders:

Each file starts with a numeric prefix (01_setup.sql, 02_profiles.sql, …). Run them sequentially inside the SQL Editor—highlight the file contents, paste, execute, then move to the next number. This mirrors Supabase’s migration order and lets you stop/re-run individual sections (e.g., only 33_ai_models.sql when adjusting AI catalogs).

Tips

# Install Supabase CLI npm install -g supabase # Login supabase login # Link project supabase link --project-ref your-project-ref # Create migration supabase migration new create_posts_table # Edit file in supabase/migrations/ # Then apply: supabase db push # Generate TypeScript types npm run db:gen

Generate TypeScript Types

npx supabase gen types typescript --project-id <id> > src/types/database.types.ts

This eliminates all any type assertions and provides full type safety.

Verify Setup

Checklist:

Troubleshooting

Error: “Invalid API key”

Solution: Verify you copied the correct key from the dashboard

Error: “Row Level Security policy violation”

Solution: Check if RLS policies are configured correctly

Error: “No API key found”

Solution: Ensure NEXT_PUBLIC_SUPABASE_* variables are in .env

Error: “Could not find the table … in the schema cache” (PGRST205)

Solution: Depois de executar SQL manualmente pelo dashboard, force o PostgREST a recarregar o schema executando:

NOTIFY pgrst, 'reload schema';

Isso limpa o cache e faz as novas tabelas aparecerem imediatamente nas rotas REST.

Outdated types

Solution: Run npm run db:gen after creating/modifying tables