Skip to content

Latest commit

 

History

History
72 lines (53 loc) · 2.15 KB

File metadata and controls

72 lines (53 loc) · 2.15 KB

Fix "fee_type column not found" Error

Quick Fix Steps

Option 1: Supabase Dashboard (Recommended)

  1. Open Supabase Dashboard

  2. Open SQL Editor

    • Click "SQL Editor" in the left sidebar
    • Click "New query"
  3. 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;
  1. Execute

    • Click "Run" or press Ctrl+Enter (Windows) / Cmd+Enter (Mac)
    • You should see "Success. No rows returned"
  2. 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'
  3. Restart Your Dev Server

    • Stop your Next.js server (Ctrl+C)
    • Restart: npm run dev

Option 2: Command Line (if you have psql)

psql $DATABASE_URL -f lib/supabase/migrations-add-fee-type.sql

Why This Error Happens

The error "Could not find the 'fee_type' column of 'contracts' in the schema cache" occurs because:

  • The code tries to insert/update fee_type in the contracts table
  • The column doesn't exist in your database yet
  • Supabase's PostgREST validates queries against a schema cache

After Running the Migration

  • 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

Still Having Issues?

If the error persists after running the migration:

  1. Wait 10-30 seconds for the schema cache to refresh
  2. Restart your Next.js dev server
  3. Check Supabase Dashboard → Table Editor → contracts table → verify fee_type column exists
  4. Clear browser cache and hard refresh (Ctrl+Shift+R or Cmd+Shift+R)