2.0 KiB
2.0 KiB
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.sqlis 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
schema.sqlmigrations/0002_add_freelancer_os_core_tables.sqlmigrations/0003_add_project_planning_assets.sqlmigrations/0004_add_business_os_tables.sqlmigrations/0005_add_advanced_crm_tables.sqlmigrations/0006_add_pgvector_and_embeddings.sqlmigrations/0007_add_client_portal_tables.sqlmigrations/0008_add_project_progress_and_quota.sqlmigrations/0009_lock_registration_after_first_admin.sqlmigrations/0010_allow_internal_auth_user_creation.sqlmigrations/0011_fix_service_role_claims_and_storage_policies.sql- 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.