feat(supabase): workspaces M1, one personal workspace per account

V1-1.1 (contract V1-1_OWNERS_ANIMALS.md §4, §8, §9). Tables workspaces and workspace_members, created with the profile by trigger through one atomic, idempotent write path; deferred invariant (a personal workspace has exactly its account as holder); backfill of existing profiles; access helpers caller_workspace_ids (active profile, confirmed email) and writable_workspace_ids; RLS select for members only; no privilege for anon or service_role. log_event keeps x-correlation-id only as a short token. pgTAP 012 (85 checks), census and types updated, config test.
This commit is contained in:
bchanot committed 2026-10-25 19:53:16 +01:00
1 parent 5d734be512
commit 7bf4fb6079
6 files changed
+923 -1

No files matched your search

+71
View File
@@ -444,6 +444,73 @@ export type Database = {
}
Relationships: []
}
workspace_members: {
Row: {
created_at: string
member_role: Database['public']['Enums']['workspace_member_role']
user_id: string
workspace_id: string
}
ComputedFields: never
Insert: {
created_at?: string
member_role: Database['public']['Enums']['workspace_member_role']
user_id: string
workspace_id: string
}
Update: {
created_at?: string
member_role?: Database['public']['Enums']['workspace_member_role']
user_id?: string
workspace_id?: string
}
Relationships: [
{
foreignKeyName: 'workspace_members_user_id_fkey'
columns: ['user_id']
isOneToOne: false
referencedRelation: 'profiles'
referencedColumns: ['id']
},
{
foreignKeyName: 'workspace_members_workspace_id_fkey'
columns: ['workspace_id']
isOneToOne: false
referencedRelation: 'workspaces'
referencedColumns: ['id']
},
]
}
workspaces: {
Row: {
created_at: string
id: string
kind: Database['public']['Enums']['workspace_kind']
personal_user_id: string | null
}
ComputedFields: never
Insert: {
created_at?: string
id?: string
kind: Database['public']['Enums']['workspace_kind']
personal_user_id?: string | null
}
Update: {
created_at?: string
id?: string
kind?: Database['public']['Enums']['workspace_kind']
personal_user_id?: string | null
}
Relationships: [
{
foreignKeyName: 'workspaces_personal_user_id_fkey'
columns: ['personal_user_id']
isOneToOne: true
referencedRelation: 'profiles'
referencedColumns: ['id']
},
]
}
}
Views: {
[_ in never]: never
@@ -588,6 +655,8 @@ export type Database = {
sheet_status: 'active' | 'archived' | 'deleted'
sheet_version_status: 'draft' | 'published' | 'deprecated'
sheet_visibility: 'private' | 'public'
workspace_kind: 'personal'
workspace_member_role: 'holder'
}
CompositeTypes: {
[_ in never]: never
@@ -726,6 +795,8 @@ export const Constants = {
sheet_status: ['active', 'archived', 'deleted'],
sheet_version_status: ['draft', 'published', 'deprecated'],
sheet_visibility: ['private', 'public'],
workspace_kind: ['personal'],
workspace_member_role: ['holder'],
},
},
} as const