Prompt file imported from maiprop/maiprop-listing-site (
.windsurf/workflows/regenerate-supabase-types.md). Copyright stays with the author.
This workflow regenerates src/integrations/supabase/types.ts to match the current
Supabase database schema. Run this whenever migrations are applied or schema changes.
Prerequisites
- Supabase CLI installed:
npm install -g supabase(ornpx supabase) - Logged into Supabase:
supabase login - Project ID:
qvvicunqcrwpioqnvzxf(from supabase/config.toml)
Steps
1. Ensure you are logged in
// turbo
npx supabase login
2. Generate types from the remote (production) DB
// turbo
npx supabase gen types typescript --project-id qvvicunqcrwpioqnvzxf --schema public > src/integrations/supabase/types.ts
3. Alternative: generate from local DB (requires supabase start)
npx supabase gen types typescript --local --schema public > src/integrations/supabase/types.ts
4. Verify TypeScript compiles
// turbo
npx tsc -p tsconfig.app.json --noEmit
5. Remove stale as any casts
Search for (supabase.from as any) and as unknown as patterns that may no
longer be needed once the generated types include previously-missing tables:
Get-ChildItem src -Recurse -Include *.ts,*.tsx | Select-String "supabase.from as any"
6. Run tests and lint
// turbo
npm run lint; npm test -- --run
Common Issues
- "Column does not exist" errors → types.ts is stale; re-run step 2.
- Auth errors → run
supabase loginagain. - Migration drift → run
supabase db pushfirst, then regenerate types.
Schema-to-Code drift detection
Run this periodically (e.g. in CI) to detect when types.ts is out of sync:
npx supabase gen types typescript --project-id qvvicunqcrwpioqnvzxf | Compare-Object (Get-Content src/integrations/supabase/types.ts)
If there is any diff, types.ts should be regenerated.
