Files
neta/supabase

Supabase Directory

This directory stores SQL files for the project's Supabase/PostgreSQL database.

One-Shot Setup

For a fresh Supabase project, use:

supabase/setup.sql

You can paste the full file into Supabase SQL Editor and run it once, or run it from the repository root with psql:

psql "postgresql://postgres:[PASSWORD]@[HOST]:5432/postgres" -v ON_ERROR_STOP=1 -f supabase/setup.sql

The setup file is generated by concatenating schema.sql and migrations 0002 through 0011 in the canonical order. Demo seed data is intentionally not included.

Current Baseline

  • schema.sql is the first registered database SQL file.
  • Its documentation is in docs/database/0001-initial-schema.md.
  • Its order is tracked in docs/database/query-order.md.
  • Execution history is tracked in docs/database/query-log.md.

Future Changes

Future schema changes should be added under:

supabase/migrations/

Optional local/demo data should be added under:

supabase/seeds/

Do not overwrite already executed SQL without also creating a new ordered migration and documenting why.

Current Ordered SQL

  1. schema.sql
  2. migrations/0002_add_freelancer_os_core_tables.sql
  3. migrations/0003_add_project_planning_assets.sql
  4. migrations/0004_add_business_os_tables.sql
  5. migrations/0005_add_advanced_crm_tables.sql
  6. migrations/0006_add_pgvector_and_embeddings.sql
  7. migrations/0007_add_client_portal_tables.sql
  8. migrations/0008_add_project_progress_and_quota.sql
  9. migrations/0009_lock_registration_after_first_admin.sql
  10. migrations/0010_allow_internal_auth_user_creation.sql
  11. migrations/0011_fix_service_role_claims_and_storage_policies.sql
  12. Optional local/demo data: seeds/0001_demo_freelancer_os_data.sql

Apply Migrations

For a new project, prefer the one-shot setup file:

psql "postgresql://postgres:[PASSWORD]@[HOST]:5432/postgres" -v ON_ERROR_STOP=1 -f supabase/setup.sql

The ordered migration files remain as the source history for future schema changes.