Database Setup

About This Page

This page helps you set up and troubleshoot the database tables needed for the application. Currently, it supports setting up the feedback system, which allows users to submit feedback through the app.

If you're experiencing issues with the feedback form, running the setup here should fix them. For advanced issues, you can use the direct database actions on the right.

Troubleshooting Tips:

  • If the automatic setup fails, try the "Run Direct SQL" button
  • After setup, test the feedback form with the "Test Feedback Insertion" button
  • Check the Supabase dashboard SQL Editor if all else fails
  • Make sure your Supabase service role key is set in the environment variables

Feedback Table Setup

Processing...

Direct Database Actions

Manual SQL Reference

If automatic methods fail, you can run this SQL in your Supabase SQL Editor:

Important: Make sure to run this SQL in the Supabase Dashboard SQL Editor if other methods fail.

  1. Log in to your Supabase dashboard
  2. Select your project
  3. Go to the SQL Editor in the left sidebar
  4. Create a new query
  5. Paste the SQL below and click Run
-- Create feedback table
CREATE TABLE IF NOT EXISTS public.feedback (
    id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
    user_name TEXT NOT NULL,
    email TEXT NOT NULL,
    subject TEXT NOT NULL,
    text TEXT NOT NULL,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL
);

-- Enable RLS
ALTER TABLE public.feedback ENABLE ROW LEVEL SECURITY;

-- Allow inserts from anyone
DROP POLICY IF EXISTS feedback_insert_policy ON public.feedback;
CREATE POLICY feedback_insert_policy ON public.feedback 
    FOR INSERT TO authenticated, anon 
    WITH CHECK (true);

-- Allow select only for specific users
DROP POLICY IF EXISTS feedback_select_policy ON public.feedback;
CREATE POLICY feedback_select_policy ON public.feedback
    FOR SELECT TO authenticated
    USING (auth.uid() IN (
        SELECT auth.uid() FROM auth.users WHERE email = 'dugoutedge@gmail.com'
    ));