feat: create canonical schema and README\n\nGenerate single schema migration and add deployment guide.

This commit is contained in:
v0
2026-03-11 05:43:40 +00:00
parent 7e50bd9673
commit c0d01b4f3a
2 changed files with 757 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
## Database Setup
### Fresh deployment
Run **one file**:
```
scripts/schema.sql
```
Paste it in Supabase → **SQL Editor → New query** and hit Run.
That is the complete, idempotent schema — all tables, enums, indexes, RLS policies, functions, and triggers.
### Existing deployment
The numbered scripts (`001_*` → `011_*`) are the **migration history** of the live database.
Do not re-run them. They are kept for reference only.
### What `schema.sql` contains
| Section | Contents |
|---------|----------|
| Extensions | `uuid-ossp` |
| Enums | 14 custom types (`member_role`, `task_status`, etc.) |
| Helper functions | `get_user_space_ids`, `user_has_role_in_space` |
| Tables | `spaces`, `space_members`, `tasks`, `projects`, `payments`, `contacts`, `knowledge_base`, `secrets`, `area_leads`, `integrations`, `comms_channels`, `comms_messages`, `activity_log` |
| Indexes | 22 performance indexes |
| RLS policies | Full row-level security on every table |
| Triggers | `on_space_created` (auto-creates 4 default channels) |
| Auth hook | `on_auth_user_created` (handles create-space and join-space signup flows) |