Course Module Database Migration Guide

⚠️ IMPORTANT: Run This First!

Before using the Courses module, you MUST run the migration SQL in your Supabase project.

If You Get "column owner_id does not exist" Error:

This means you have an existing courses table with the old structure. Use the migration script instead:

  1. Open Supabase Dashboard

    • Go to your Supabase project

    • Navigate to SQL Editor

  2. Run the Migration Script

    • Copy the entire contents of migrate-courses-table.sql

    • Paste it into the SQL Editor

    • Click Run or press Ctrl+Enter

    • This will safely migrate your existing table

  3. If You Don't Have an Existing Courses Table:

    • Use supabase-schema.sql instead (for fresh installations)

Steps to Migrate (Using migrate-courses-table.sql):

  1. Open Supabase Dashboard

    • Go to your Supabase project

    • Navigate to SQL Editor

  2. Run the Migration SQL

    • Copy the entire contents of migrate-courses-table.sql

    • Paste it into the SQL Editor

    • Click Run or press Ctrl+Enter

  3. Verify Tables Created

    • Go to DatabaseTables

    • You should see these new/updated tables:

      • courses (updated structure with owner_id)

      • modules (new)

      • user_course_progress (new)

If You Have Existing Courses Table:

If you already have a courses table with the old structure, run this migration:

After Migration:

  1. Test the Courses Page

    • Go to http://localhost:8080/courses

    • Browse the library and open a course detail page

    • Check browser console for any errors

  2. If You Still See 400/404 Errors:

    • Check Supabase logs: LogsPostgres Logs

    • Verify RLS policies are created

    • Check that your user is authenticated

Troubleshooting:

Error: "relation courses does not exist"

  • Run the full supabase-schema.sql file

Error: "column owner_id does not exist"

  • Run the migration SQL above to add new columns

Error: "permission denied"

  • Check that RLS policies were created

  • Verify you're logged in

  • Check Supabase → Authentication → Policies

Error: "No API key found"

  • This is a Gemini API issue, not database

  • Check that the API key is correct in src/lib/gemini.ts

  • Verify the key is valid in Google AI Studio

Last updated