Skip to main content
8Space uses PostgreSQL via Supabase with a comprehensive schema supporting multi-tenancy, projects, tasks, and collaboration features.

Entity Relationship Diagram

Core Tables

Multi-Tenancy Layer

Purpose: Workspace/organization container for projectsKey Features:
  • URL-safe slug for routing (e.g., /app/:tenantSlug/projects)
  • Soft delete via archived_at
  • Unique constraint on slug

Project Management

Key Relationships:
  • Belongs to exactly one tenant
  • Has many tasks, workflow columns, labels
  • Soft delete via archived_at

Task Management

Key Features:
  • Lexicographic order_rank for drag-and-drop ordering
  • Date validation constraint
  • Milestone support
  • Effort estimation

Database Functions

Tenant Management

Purpose: Create new tenant workspace with auto-generated slugBehavior:
  • Normalizes slug from name if not provided
  • Handles slug conflicts with numeric suffixes
  • Automatically adds creator as owner
  • Returns created tenant record
Example:
Purpose: Convert arbitrary text to URL-safe slugTransformations:
  • Lowercase conversion
  • Replace non-alphanumeric with hyphens
  • Remove leading/trailing hyphens
  • Fallback to ‘space’ if empty
Example:

Project Management

Purpose: Create project with default workflow columnsBehavior:
  1. Validates tenant membership
  2. Creates project record
  3. Adds all tenant members as project members
  4. Creates default workflow columns (Backlog, To Do, In Progress, Done)
  5. Returns project ID
Role Mapping:
  • Creator → owner
  • Tenant owners/admins → editor
  • Tenant members → viewer
Purpose: Aggregate project analyticsReturns:

Task Operations

Purpose: Move task between workflow columnsBehavior:
  1. Validates task and column existence
  2. Checks user permissions (can_edit_project)
  3. Updates status_column_id and order_rank
  4. Logs activity event
  5. Returns updated task
Used by: Drag-and-drop in Kanban board

Permission Helpers

All permission functions are marked security definer and set search_path = public to prevent SQL injection and privilege escalation.

Row Level Security (RLS)

Tenant Policies

Project Policies

RLS policies are automatically enforced on all queries, even from backend functions. This provides defense-in-depth security.

Task Policies

Triggers

Applied to: profiles, workflow_columns, tasks, task_checklist_items

Indexes

Migration History

1

20260212220000_init_gantt_mvp.sql

Initial schema with projects, tasks, workflow columns, and basic RLS
2

20260213220000_auto_join_new_users.sql

Single-tenant mode: auto-add users to all projects
3

20260213220100_handle_new_user_google_compat.sql

Google OAuth metadata support for profile creation
4

20260216220000_fix_create_project_trigger_conflict.sql

Fixed duplicate project member insertions
5

20260217143000_multi_tenant_onboarding.sql

Multi-tenant architecture with tenant tables and updated functions

Next Steps

Multi-Tenancy Design

Deep dive into tenant isolation and permission model