-
Open Supabase Dashboard
- Go to https://supabase.com/dashboard
- Select your project
-
Open SQL Editor
- Click "SQL Editor" in the left sidebar
- Click "New query"
-
Run the Migration
- Copy and paste this SQL:
-- Add fee_type column to contracts table
ALTER TABLE public.contracts
ADD COLUMN IF NOT EXISTS fee_type TEXT CHECK (fee_type IN ('fixed', 'percentage')) DEFAULT 'fixed';
-- Update existing contracts to have 'fixed' fee type
UPDATE public.contracts
SET fee_type = 'fixed'
WHERE fee_type IS NULL;-
Execute
- Click "Run" or press
Ctrl+Enter(Windows) /Cmd+Enter(Mac) - You should see "Success. No rows returned"
- Click "Run" or press
-
Verify (Optional)
- Run this to verify the column exists:
SELECT column_name, data_type, column_default FROM information_schema.columns WHERE table_name = 'contracts' AND column_name = 'fee_type';
- You should see one row with
fee_type,text, and default'fixed'
-
Restart Your Dev Server
- Stop your Next.js server (
Ctrl+C) - Restart:
npm run dev
- Stop your Next.js server (
psql $DATABASE_URL -f lib/supabase/migrations-add-fee-type.sqlThe error "Could not find the 'fee_type' column of 'contracts' in the schema cache" occurs because:
- The code tries to insert/update
fee_typein the contracts table - The column doesn't exist in your database yet
- Supabase's PostgREST validates queries against a schema cache
- The column will be added to your database
- Supabase's schema cache will refresh automatically (may take a few seconds)
- Your Next.js app should work without errors
If the error persists after running the migration:
- Wait 10-30 seconds for the schema cache to refresh
- Restart your Next.js dev server
- Check Supabase Dashboard → Table Editor →
contractstable → verifyfee_typecolumn exists - Clear browser cache and hard refresh (
Ctrl+Shift+RorCmd+Shift+R)