Made Open

Database Schema Reference (Definitive)

Auto-generated from supabase/migrations/00001 through 00047. 135 tables documented here across 47 migrations, on Supabase PostgreSQL with pgvector.

Coverage gap (audit 2026-04-12): The repository now has 53 migration files producing 177 unique tables (180 CREATE TABLE statements; organizations, intentions, and context_snapshots are re-declared with IF NOT EXISTS in later migrations). Migrations 00048_provider_abstraction.sql, 00049_unified_life_foundation.sql, 00050_intentions_project_management.sql, 00051_life_domains_part1.sql, 00052_life_domains_part2.sql, and 00053_entity_registry_backfill.sql are not yet reflected in the per-table sections below. For the authoritative full-table inventory see data-model-complete.md and the raw migration SQL under supabase/migrations/.


Table of Contents


Extensions

Enabled in migration 00001:

ExtensionPurpose
uuid-osspUUID generation
pgcryptoCryptographic functions (gen_random_uuid, gen_random_bytes)
vectorpgvector -- vector embeddings and similarity search
pg_cronScheduled jobs (enabled in 00018)

Functions and Triggers (shared)

set_updated_at() (00033)

CREATE OR REPLACE FUNCTION set_updated_at()
RETURNS TRIGGER LANGUAGE plpgsql AS $$
BEGIN NEW.updated_at = now(); RETURN NEW; END;
$$;

Used by: audio_sessions, voice_commands

trigger_set_updated_at()

Referenced by migrations 00041-00047 for updated_at auto-update on: inventory_items, inventory_spaces, inventory_maintenance, inbox_items, phone_lines, ivr_flows, email_folders, email_threads, email_signatures, meetings, meeting_participants, meeting_recordings, contact_notes.

update_user_preferences_updated_at() (00026)

CREATE OR REPLACE FUNCTION update_user_preferences_updated_at()
RETURNS TRIGGER LANGUAGE plpgsql AS $$
BEGIN NEW.updated_at = now(); RETURN NEW; END;
$$;

update_schedules_updated_at() (00038)

Same pattern, dedicated to the schedules table.

prevent_inventory_event_mutation() (00041)

Raises an exception on UPDATE or DELETE to enforce append-only on inventory_events.

append_command_progress() (00036)

CREATE OR REPLACE FUNCTION append_command_progress(
  p_command_id uuid, p_owner_id uuid, p_entry jsonb
) RETURNS void

Atomically appends a progress entry to device_commands.progress JSONB array. SECURITY DEFINER.


Scheduled Jobs (pg_cron)

Defined in migration 00018:

NameScheduleAction
process-retention-daily0 2 * * * (daily 2 AM UTC)Calls Edge Function process-retention
check-audit-alerts*/15 * * * * (every 15 min)Calls Edge Function check-audit-alerts
sync-presence* * * * * (every minute)Calls Edge Function sync-presence
weekly-digest0 8 * * 1 (Mon 8 AM UTC)Calls Edge Function weekly-digest
expire-document-jobs0 3 * * * (daily 3 AM UTC)Expires pending document_jobs older than 7 days

Migration 00001 -- Initial Schema

persons

Core contact entity. All contacts from all sources land here.

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
nametextNOT NULL
emailsjsonbdefault '[]'
phonesjsonbdefault '[]'
addressesjsonbdefault '[]'
tagsjsonbdefault '[]'
birthdaydate
notestext
avatar_urltext
sourcesjsonbdefault '[]'
aliasestext[]NOT NULL default '{}' (added 00033)
phonetic_keytext(added 00033)
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their persons" ON persons
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • persons_phonetic on (owner_id, phonetic_key) WHERE phonetic_key IS NOT NULL (00033)
  • persons_aliases using GIN on (aliases) WHERE array_length(aliases, 1) > 0 (00033)

Services: DataService (CRUD), ETLService (sync from MS Graph), RulesService (tag updates), EntityMergeService (merge/delete), ContactTimelineService (tag/merge updates)


organizations

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
nametextNOT NULL
domaintext
industrytext
addressjsonb
phonetext
websitetext
sourcesjsonbdefault '[]'
slugtextUNIQUE (added 00022)
avatar_urltext(added 00022)
billing_plantextdefault 'free', CHECK IN ('free','pro','team','enterprise') (added 00022)
billing_statustextdefault 'active', CHECK IN ('active','past_due','canceled','trialing') (added 00022)
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their organizations" ON organizations
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

(WITH CHECK added in 00039)

Indexes:

  • organizations_owner_id on (owner_id) (00022)
  • organizations_slug on (slug) (00022)

Services: DataService (CRUD)


channels

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
plugin_idtextNOT NULL
typetextNOT NULL
nametextNOT NULL
capabilitiesjsonbdefault '{}'
configjsonbdefault '{}'
enabledbooleandefault true
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their channels" ON channels
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

(WITH CHECK added in 00039)

Services: ChannelService, ConnectorService


conversations

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
titletext
channel_iduuidFK channels(id)
typetextNOT NULL
participantsjsonbdefault '[]'
thread_typetextNOT NULL default 'single_channel' (added 00042)
related_conversation_idsuuid[]default '{}' (added 00042)
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their conversations" ON conversations
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

(WITH CHECK added in 00039)

Foreign Keys: channel_id -> channels(id)

Services: DataService (CRUD), InboxService (cross-channel queries)


messages

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
conversation_iduuidFK conversations(id)
sender_person_iduuidFK persons(id)
directiontextNOT NULL
bodytext
content_typetextdefault 'text/plain'
timestamptimestamptzNOT NULL
provider_message_idtext
metadatajsonbdefault '{}'
email_thread_iduuidFK email_threads(id) ON DELETE SET NULL (added 00044)
folder_iduuidFK email_folders(id) ON DELETE SET NULL (added 00044)
ccjsonbdefault '[]' (added 00044)
bccjsonbdefault '[]' (added 00044)
reply_totext(added 00044)
has_attachmentsbooleandefault false (added 00044)
is_draftbooleandefault false (added 00044)
subjecttext(added 00044)
from_addresstext(added 00044)
to_addressesjsonbdefault '[]' (added 00044)
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their messages" ON messages
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

(WITH CHECK added in 00039)

Indexes:

  • (conversation_id, timestamp DESC) (00001)
  • (owner_id, timestamp DESC) (00001)
  • idx_messages_email_thread on (email_thread_id, timestamp DESC) (00044)
  • idx_messages_folder on (owner_id, folder_id, timestamp DESC) (00044)
  • idx_messages_draft on (owner_id, is_draft) WHERE is_draft = true (00044)

Foreign Keys: conversation_id -> conversations(id), sender_person_id -> persons(id), email_thread_id -> email_threads(id), folder_id -> email_folders(id)

Services: DataService (CRUD), ETLService (sync), EmailService (draft CRUD, move, flag)


attachments

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
message_iduuidFK messages(id)
storage_pathtextNOT NULL
mime_typetextNOT NULL
filenametext
size_bytesint
owner_iduuidNOT NULL, FK auth.users(id) (added 00039)
created_attimestamptzdefault now()

RLS: Enabled (added in 00039).

CREATE POLICY "users own their attachments" ON attachments
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Foreign Keys: message_id -> messages(id)

Services: DataService (CRUD)


events

Calendar events.

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
titletextNOT NULL
descriptiontext
start_timetimestamptzNOT NULL
end_timetimestamptz
locationtext
location_geopoint
attendeesjsonbdefault '[]'
organizer_iduuidFK persons(id)
all_daybooleandefault false
recurrencejsonb
sourcesjsonbdefault '[]'
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their events" ON events
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

(WITH CHECK added in 00039)

Indexes: (owner_id, start_time) (00001)

Foreign Keys: organizer_id -> persons(id)

Services: DataService (CRUD), ETLService (sync from MS Graph), MeetingService (calendar_event_id link)


locations

Named places/geofences.

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
nametext
addresstext
coordinatespoint
typetext
phonetext
radius_metersintdefault 100
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their locations" ON locations
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

(WITH CHECK added in 00039)

Services: DataService (CRUD), InventoryService (location_id reference)


devices

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
nametextNOT NULL
platformtextNOT NULL
owner_iduuidFK auth.users(id)
device_tokentextUNIQUE
last_seen_attimestamptz
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their devices" ON devices
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

(WITH CHECK added in 00039)

Services: DataService (CRUD), DeviceCommandService


location_history

Time-series device location data.

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
device_iduuidFK devices(id)
latfloat8NOT NULL
lonfloat8NOT NULL
accuracy_mfloat4 / real
altitude_mfloat4 / real
speed_mpsfloat4
wifi_ssidtext
ssidtext(added 00002, separate column)
owner_iduuidFK auth.users(id) (added 00002, hardened 00039)
recorded_attimestamptzNOT NULL
created_attimestamptzdefault now()

RLS: Enabled (added in 00039).

CREATE POLICY "users own their location_history" ON location_history
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • (device_id, recorded_at DESC) (00001)
  • location_history_owner_time on (owner_id, recorded_at DESC) (00002)

Foreign Keys: device_id -> devices(id)

Services: DataService (write from Android app), RulesService (geofence evaluation)


tasks

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
titletextNOT NULL
descriptiontext
due_datetimestamptz
statustextdefault 'pending'
prioritytextdefault 'medium'
assignee_iduuidFK persons(id)
related_eventuuidFK events(id)
sourcesjsonbdefault '[]'
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their tasks" ON tasks
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

(WITH CHECK added in 00039)

Foreign Keys: assignee_id -> persons(id), related_event -> events(id)

Services: DataService (CRUD), ETLService (insert), AudioETLService (insert from extracted intelligence), RulesService (insert)


documents

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
titletextNOT NULL
contenttext
storage_pathtext
mime_typetext
created_byuuidFK persons(id)
sourcetext
source_idtext
tagsjsonbdefault '[]'
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their documents" ON documents
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

(WITH CHECK added in 00039)

Foreign Keys: created_by -> persons(id)

Services: DataService (CRUD), ETLService (insert)


rules

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
nametextNOT NULL
descriptiontext
enabledbooleandefault true
trigger_event_typestext[]NOT NULL
condition_astjsonbNOT NULL
actionsjsonb[]NOT NULL
priorityintdefault 100
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their rules" ON rules
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

(WITH CHECK added in 00039)

Services: RulesService (evaluate), ToolRegistry (query for AI agent), DataService (CRUD)


job_records

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidFK auth.users(id)
job_typetextNOT NULL
queuetextNOT NULL
payloadjsonbNOT NULL
statustextdefault 'enqueued'
attemptsintdefault 0
last_errortext
triggered_by_event_idtext
correlation_idtext
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Not enabled (service-role only access).

Services: JobQueueService


audit_log

Append-only. No UPDATE or DELETE policies.

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidFK auth.users(id)
actor_typetextNOT NULL
actor_idtextNOT NULL
actiontextNOT NULL
resource_typetextNOT NULL
resource_idtext
outcometextNOT NULL
metadatajsonbdefault '{}'
occurred_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users can read their audit log" ON audit_log
  FOR SELECT USING (auth.uid() = owner_id);

INSERT allowed for service role only. No UPDATE or DELETE policies -- append-only by design.

Indexes:

  • (owner_id, occurred_at DESC) (00001)
  • (actor_id, occurred_at DESC) (00001)

Services: PolicyService (insert), AuditService (read/query)


embeddings

pgvector embeddings for semantic search.

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
entity_typetextNOT NULL
entity_iduuidNOT NULL
modeltextNOT NULL
embeddingvector(1536)
created_attimestamptzdefault now()

Unique: (owner_id, entity_type, entity_id)

RLS: Enabled.

CREATE POLICY "users own their embeddings" ON embeddings
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

(WITH CHECK added in 00039)

Indexes: IVFFlat on (embedding vector_cosine_ops) with lists=100

Services: EmbeddingPipelineService, SearchService


Migration 00002 -- Intentions

intentions

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
typetextNOT NULL, CHECK IN ('reminder','task','goal','commitment')
titletextNOT NULL
descriptiontext
due_attimestamptz
recurrence_ruletextiCal RRULE
statustextNOT NULL default 'pending', CHECK IN ('pending','in_progress','completed','cancelled')
entity_refjsonbe.g. {"table":"events","id":"uuid"}
boss_job_idtextpg-boss job ID
metajsonbdefault '{}'
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their intentions" ON intentions
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: intentions_owner_due on (owner_id, due_at) WHERE status = 'pending'

Services: IntentionsService (CRUD, scheduling)


presence_snapshots

Durable snapshot of ephemeral presence state (primary in Redis).

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
dimensiontextNOT NULL ('location', 'activity', 'active_app', 'availability')
state_jsonjsonbNOT NULL
recorded_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their presence snapshots" ON presence_snapshots
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: presence_snapshots_owner_dim_time on (owner_id, dimension, recorded_at DESC)

Services: PresenceService


Migration 00003 -- Sovereign AI

agent_conversations

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
titletext
messagesjsonbNOT NULL default '[]'
context_jsonjsonbdefault '{}'
model_usedtext
token_countintegerdefault 0
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their agent conversations" ON agent_conversations
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: agent_conversations_owner_updated on (owner_id, updated_at DESC)

Services: AgentService (insert/update)


workflow_definitions

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
nametextNOT NULL
descriptiontext
definitionjsonbNOT NULL
enabledbooleandefault true
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their workflow definitions" ON workflow_definitions
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Services: WorkflowService (CRUD)


workflow_runs

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
workflow_iduuidNOT NULL, FK workflow_definitions(id)
statustextNOT NULL default 'running', CHECK IN ('running','paused','completed','failed','cancelled')
trigger_contextjsonbdefault '{}'
step_contextjsonbdefault '{}'
current_steptext
errortext
started_attimestamptzdefault now()
completed_attimestamptz

RLS: Enabled.

CREATE POLICY "users own their workflow runs" ON workflow_runs
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: workflow_runs_owner_status on (owner_id, status, started_at DESC)

Foreign Keys: workflow_id -> workflow_definitions(id)

Services: WorkflowService (insert/update)


llm_usage

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
providertextNOT NULL ('openrouter', 'ollama')
modeltextNOT NULL
prompt_tokensintegerNOT NULL default 0
completion_tokensintegerNOT NULL default 0
cost_usdnumeric(10,6)default 0
routing_reasontext
conversation_iduuidnullable
recorded_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their llm usage" ON llm_usage
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: llm_usage_owner_month on (owner_id, date_trunc('month', recorded_at AT TIME ZONE 'UTC'))

Services: LLMRoutingService (insert), AgentService


Migration 00004 -- Federation

dids

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
didtextNOT NULL UNIQUE
methodtextNOT NULL, CHECK IN ('key','web')
documentjsonbNOT NULL (W3C DID Document)
public_key_b58textNOT NULL
private_key_enctextencrypted private key
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their dids" ON dids
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: dids_owner on (owner_id)

Services: DIDService (CRUD)


verifiable_credentials

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
vc_jsonjsonbNOT NULL (full W3C VC)
vc_typetextNOT NULL
issuer_didtextNOT NULL
subject_didtextNOT NULL
issued_attimestamptzNOT NULL
expires_attimestamptz
revokedbooleandefault false
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their verifiable credentials" ON verifiable_credentials
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • vc_owner_type on (owner_id, vc_type)
  • vc_subject_did on (subject_did)

Services: VCService (issue, verify, insert)


federated_actors

Cached ActivityPub actor documents.

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
actor_urltextNOT NULL UNIQUE
actor_jsonjsonbNOT NULL
inbox_urltext
fetched_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Not enabled (public cache).

Indexes: federated_actors_url on (actor_url)

Services: ActivityPubService (insert/query)


follows

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
follower_actor_urltextNOT NULL
following_actor_urltextNOT NULL
statustextNOT NULL default 'pending', CHECK IN ('pending','accepted','rejected','cancelled')
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

Unique: (follower_actor_url, following_actor_url)

RLS: Enabled.

CREATE POLICY "users own their follows" ON follows
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: follows_owner on (owner_id, status)

Services: ActivityPubService (insert/update)


activities

ActivityPub activity log.

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
activity_idtextNOT NULL UNIQUE
activity_typetextNOT NULL
actor_urltextNOT NULL
object_jsonjsonbdefault '{}'
directiontextNOT NULL, CHECK IN ('inbound','outbound')
processedbooleandefault false
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their activities" ON activities
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: activities_owner_dir on (owner_id, direction, created_at DESC)

Services: ActivityPubService (insert/update)


didcomm_messages

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
message_idtextNOT NULL UNIQUE
from_didtextNOT NULL
to_didtextNOT NULL
message_typetextNOT NULL
body_jsonjsonbNOT NULL
directiontextNOT NULL, CHECK IN ('inbound','outbound')
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their didcomm messages" ON didcomm_messages
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: didcomm_owner_dir on (owner_id, direction, created_at DESC)

Services: DIDCommService (insert)


Migration 00005 -- Marketplace

listings

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
listing_typetextNOT NULL, CHECK IN ('data_product','service','physical','digital')
titletextNOT NULL
descriptiontext
price_amountnumeric(12,2)
price_currencytextdefault 'USD'
price_typetextCHECK IN ('fixed','hourly','negotiable','free','time_credit')
statustextNOT NULL default 'draft', CHECK IN ('draft','active','paused','sold','expired')
tagstext[]default '{}'
location_preftext
visibilitytextNOT NULL default 'public', CHECK IN ('public','followers','private')
data_product_iduuidFK to data_products (nullable)
federated_ap_idtext
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "owners manage their listings" ON listings
  USING (auth.uid() = owner_id OR visibility = 'public')
  WITH CHECK (auth.uid() = owner_id);

Indexes:

  • listings_owner on (owner_id, status)
  • listings_type_status on (listing_type, status, created_at DESC)
  • listings_tags using GIN on (tags)

Services: MarketplaceService (CRUD, status update)


data_products

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
nametextNOT NULL
descriptiontext
query_defjsonbNOT NULL
privacy_policyjsonbNOT NULL default '{}'
output_formattextNOT NULL default 'json', CHECK IN ('json','csv','parquet')
sample_rowsintegerdefault 0
schema_jsonjsonb
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "owners manage their data products" ON data_products
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Services: DataProductBuilder


marketplace_transactions

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
listing_iduuidNOT NULL, FK listings(id)
buyer_iduuidNOT NULL, FK auth.users(id)
seller_iduuidNOT NULL, FK auth.users(id)
amountnumeric(12,2)
currencytextdefault 'USD'
statustextNOT NULL default 'created', CHECK IN ('created','funded','delivered','confirmed','disputed','refunded','completed')
escrow_reftext
dispute_reasontext
completed_attimestamptz
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "participants see their transactions" ON marketplace_transactions
  USING (auth.uid() = buyer_id OR auth.uid() = seller_id);

Indexes:

  • txn_buyer on (buyer_id, status)
  • txn_seller on (seller_id, status)

Foreign Keys: listing_id -> listings(id)

Services: MarketplaceService


declarations

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
decl_typetextNOT NULL, CHECK IN ('offer','need','willing_to_do')
categorytextNOT NULL
titletextNOT NULL
descriptiontext
exchange_typetextNOT NULL, CHECK IN ('reciprocal','gift','time_credit','monetary')
location_preftext
expires_attimestamptz
statustextNOT NULL default 'active', CHECK IN ('active','matched','expired','cancelled')
federated_ap_idtext
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "owners manage their declarations" ON declarations
  USING (auth.uid() = owner_id OR status = 'active')
  WITH CHECK (auth.uid() = owner_id);

Indexes:

  • declarations_owner on (owner_id, status)
  • declarations_category on (category, decl_type, status)

Services: ResourceCoordinationService (CRUD, cancel)


exchanges

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
offer_decl_iduuidFK declarations(id)
need_decl_iduuidFK declarations(id)
offer_user_iduuidNOT NULL, FK auth.users(id)
need_user_iduuidNOT NULL, FK auth.users(id)
statustextNOT NULL default 'interest', CHECK IN ('interest','negotiating','agreed','exchanging','confirming','completed','cancelled')
exchange_typetext
notestext
completed_attimestamptz
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "participants see their exchanges" ON exchanges
  USING (auth.uid() = offer_user_id OR auth.uid() = need_user_id);

Indexes:

  • exchanges_offer_user on (offer_user_id, status)
  • exchanges_need_user on (need_user_id, status)

Foreign Keys: offer_decl_id -> declarations(id), need_decl_id -> declarations(id)

Services: ResourceCoordinationService


trust_relationships

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
trusted_didtextNOT NULL
weightnumeric(3,2)NOT NULL default 1.0, CHECK weight > 0 AND weight <= 1.0
contexttext
created_attimestamptzdefault now()

Unique: (owner_id, trusted_did)

RLS: Enabled.

CREATE POLICY "owners manage their trust" ON trust_relationships
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Services: ReputationService (CRUD, delete)


reputation_scores

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
domaintextNOT NULL
scorenumeric(5,2)NOT NULL default 0
vc_countintegerdefault 0
last_computedtimestamptzdefault now()

Unique: (owner_id, domain)

RLS: Enabled.

CREATE POLICY "reputation scores are public" ON reputation_scores FOR SELECT USING (true);
CREATE POLICY "system can write reputation scores" ON reputation_scores FOR ALL USING (auth.uid() = owner_id);

Services: ReputationService


Migration 00006 -- Governance

daos

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
nametextNOT NULL
descriptiontext
slugtextNOT NULL UNIQUE
dao_typetextNOT NULL default 'community', CHECK IN ('community','cooperative','collective','trust')
quorum_pctnumeric(5,2)NOT NULL default 50.0
pass_thresholdnumeric(5,2)NOT NULL default 50.0
voting_period_hintegerNOT NULL default 168
is_publicbooleandefault true
treasury_creditsnumeric(12,2)default 0
federated_ap_idtext
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "public daos are readable" ON daos FOR SELECT USING (is_public = true OR auth.uid() = owner_id);
CREATE POLICY "owners manage their daos" ON daos USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • daos_owner on (owner_id)
  • daos_slug on (slug)

Services: DAOService


dao_members

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
dao_iduuidNOT NULL, FK daos(id) ON DELETE CASCADE
user_iduuidNOT NULL, FK auth.users(id)
roletextNOT NULL default 'member', CHECK IN ('admin','member','observer')
joined_attimestamptzdefault now()

Unique: (dao_id, user_id)

RLS: Enabled.

CREATE POLICY "dao members can see membership" ON dao_members
  FOR SELECT USING (auth.uid() = user_id OR EXISTS (SELECT 1 FROM daos WHERE id = dao_id AND (is_public = true OR owner_id = auth.uid())));
CREATE POLICY "admins manage membership" ON dao_members
  USING (EXISTS (SELECT 1 FROM dao_members dm WHERE dm.dao_id = dao_id AND dm.user_id = auth.uid() AND dm.role = 'admin') OR auth.uid() = user_id)
  WITH CHECK (EXISTS (SELECT 1 FROM dao_members dm WHERE dm.dao_id = dao_id AND dm.user_id = auth.uid() AND dm.role = 'admin'));

Indexes:

  • dao_members_dao on (dao_id, role)
  • dao_members_user on (user_id)

Services: DAOService (CRUD, delete)


proposals

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
dao_iduuidNOT NULL, FK daos(id) ON DELETE CASCADE
author_iduuidNOT NULL, FK auth.users(id)
titletextNOT NULL
descriptiontext
proposal_typetextNOT NULL default 'general', CHECK IN ('general','treasury','membership','rule_change','dispute_resolution','resource_allocation')
statustextNOT NULL default 'draft', CHECK IN ('draft','active','passed','rejected','expired','executed')
action_payloadjsonb
votes_yesintegerNOT NULL default 0
votes_nointegerNOT NULL default 0
votes_abstainintegerNOT NULL default 0
quorum_reachedbooleandefault false
voting_opens_attimestamptz
voting_closes_attimestamptz
executed_attimestamptz
federated_ap_idtext
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "dao members can see proposals" ON proposals FOR SELECT
  USING (EXISTS (SELECT 1 FROM dao_members WHERE dao_id = proposals.dao_id AND user_id = auth.uid())
         OR EXISTS (SELECT 1 FROM daos WHERE id = proposals.dao_id AND is_public = true));
CREATE POLICY "members create proposals" ON proposals FOR INSERT
  WITH CHECK (EXISTS (SELECT 1 FROM dao_members WHERE dao_id = proposals.dao_id AND user_id = auth.uid() AND role IN ('admin','member')));
CREATE POLICY "authors update draft proposals" ON proposals FOR UPDATE
  USING (auth.uid() = author_id AND status = 'draft');

Indexes:

  • proposals_dao on (dao_id, status)
  • proposals_author on (author_id)

Services: ProposalService, VotingService (vote count updates)


votes

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
proposal_iduuidNOT NULL, FK proposals(id) ON DELETE CASCADE
voter_iduuidNOT NULL, FK auth.users(id)
choicetextNOT NULL, CHECK IN ('yes','no','abstain')
weightnumeric(10,4)NOT NULL default 1.0
voted_attimestamptzdefault now()

Unique: (proposal_id, voter_id)

RLS: Enabled.

CREATE POLICY "voters own their votes" ON votes
  USING (auth.uid() = voter_id) WITH CHECK (auth.uid() = voter_id);
CREATE POLICY "dao members can read votes" ON votes FOR SELECT
  USING (EXISTS (SELECT 1 FROM proposals p JOIN dao_members dm ON dm.dao_id = p.dao_id WHERE p.id = votes.proposal_id AND dm.user_id = auth.uid()));

Indexes:

  • votes_proposal on (proposal_id, choice)
  • votes_voter on (voter_id)

Services: VotingService


time_credits

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
balancenumeric(12,2)NOT NULL default 0
lifetime_earnednumeric(12,2)NOT NULL default 0
lifetime_spentnumeric(12,2)NOT NULL default 0
updated_attimestamptzdefault now()

Unique: (owner_id)

RLS: Enabled.

CREATE POLICY "users own their time credit balance" ON time_credits
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Services: TimeBankService (credit/debit)


time_credit_transactions

Append-only ledger.

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
amountnumeric(12,2)NOT NULL
balance_afternumeric(12,2)NOT NULL
tx_typetextNOT NULL, CHECK IN ('exchange_credit','exchange_debit','governance_reward','dao_treasury_deposit','dao_treasury_withdrawal','admin_adjustment')
reference_idtext
notetext
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users see their own credit transactions" ON time_credit_transactions
  FOR SELECT USING (auth.uid() = owner_id);

Indexes: tc_tx_owner on (owner_id, created_at DESC)

Services: TimeBankService


disputes

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) (claimant)
respondent_iduuidNOT NULL, FK auth.users(id)
subject_typetextNOT NULL, CHECK IN ('exchange','listing','dao_action','other')
subject_idtext
descriptiontextNOT NULL
evidence_jsonjsonbdefault '[]'
statustextNOT NULL default 'open', CHECK IN ('open','under_review','resolved','dismissed','escalated')
resolutiontext
resolved_byuuidFK auth.users(id)
moderator_iduuidFK auth.users(id)
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "parties see their disputes" ON disputes FOR SELECT
  USING (auth.uid() = owner_id OR auth.uid() = respondent_id OR auth.uid() = moderator_id);
CREATE POLICY "claimants create disputes" ON disputes FOR INSERT WITH CHECK (auth.uid() = owner_id);
CREATE POLICY "moderators update disputes" ON disputes FOR UPDATE
  USING (auth.uid() = moderator_id OR auth.uid() = owner_id);

Indexes:

  • disputes_owner on (owner_id, status)
  • disputes_respondent on (respondent_id)
  • disputes_moderator on (moderator_id, status)

Services: DisputeService


moderation_actions

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
moderator_iduuidNOT NULL, FK auth.users(id)
target_typetextNOT NULL
target_idtextNOT NULL
actiontextNOT NULL, CHECK IN ('warn','hide','remove','ban','restore')
reasontext
notestext
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "moderators create and see actions" ON moderation_actions
  FOR ALL USING (auth.uid() = moderator_id) WITH CHECK (auth.uid() = moderator_id);

Indexes:

  • mod_actions_target on (target_type, target_id)
  • mod_actions_moderator on (moderator_id, created_at DESC)

Services: ModerationService


Migration 00007 -- Web3

wallet_connections

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
chaintextNOT NULL, CHECK IN ('ethereum','solana','polygon')
addresstextNOT NULL
providertextNOT NULL, CHECK IN ('metamask','walletconnect','phantom','injected')
is_verifiedbooleandefault false
connected_attimestamptzdefault now()

Unique: (owner_id, chain, address)

RLS: Enabled.

CREATE POLICY "users own their wallet connections" ON wallet_connections
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: wallet_connections_owner on (owner_id)

Services: WalletService (CRUD, delete)


time_credit_bridge_requests

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
directiontextNOT NULL, CHECK IN ('mint','burn')
amountnumeric(12,2)NOT NULL
chaintextNOT NULL
wallet_addresstextNOT NULL
tx_hashtext
statustextNOT NULL default 'pending', CHECK IN ('pending','confirmed','failed')
created_attimestamptzdefault now()
confirmed_attimestamptz

RLS: Enabled.

CREATE POLICY "users own their bridge requests" ON time_credit_bridge_requests
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: bridge_requests_owner on (owner_id, status)

Services: WalletService


Migration 00008 -- Federated Marketplace

federated_listing_cache

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
source_hub_urltextNOT NULL
remote_listing_idtextNOT NULL
titletextNOT NULL
descriptiontext
listing_typetextNOT NULL default 'service'
credits_per_hournumeric(10,2)
tagstext[]default '{}'
actor_urltext
raw_ap_objectjsonb
cached_attimestamptzdefault now()
expires_attimestamptzdefault now() + interval '24 hours'

Unique: (owner_id, source_hub_url, remote_listing_id)

RLS: Enabled.

CREATE POLICY "users manage their federation cache" ON federated_listing_cache
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • fed_listing_hub on (owner_id, source_hub_url)
  • fed_listing_expires on (expires_at)

Services: FederatedMarketplaceService (insert)


hub_subscriptions

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
hub_urltextNOT NULL
hub_nametext
actor_urltext
is_activebooleandefault true
last_synctimestamptz
created_attimestamptzdefault now()

Unique: (owner_id, hub_url)

RLS: Enabled.

CREATE POLICY "users manage their hub subscriptions" ON hub_subscriptions
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: hub_subs_owner on (owner_id, is_active)

Services: FederatedMarketplaceService (CRUD, delete, update)


Migration 00009 -- Calling

call_sessions

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
call_sidtext
from_numbertextNOT NULL
to_numbertextNOT NULL
directiontextNOT NULL, CHECK IN ('inbound','outbound')
statustextNOT NULL default 'initiated', CHECK IN ('initiated','ringing','in-progress','completed','failed','busy','no-answer')
started_attimestamptzdefault now()
ended_attimestamptz
duration_secondsinteger
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their call sessions" ON call_sessions
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • call_sessions_owner on (owner_id, started_at DESC)
  • call_sessions_sid on (call_sid)

Services: TwilioCallingService (insert/update), ToolRegistry (query call_analyses by call_session_id)


Migration 00010 -- Agent Memory

agent_memory

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
session_idtextNOT NULL
memory_typetextNOT NULL default 'working', CHECK IN ('working','episodic','semantic')
keytextNOT NULL
valuejsonbNOT NULL
expires_attimestamptz
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

Unique: (owner_id, session_id, key)

RLS: Enabled.

CREATE POLICY "users own their agent memory" ON agent_memory
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: agent_memory_session on (owner_id, session_id)

Services: AgentMemoryService (CRUD, delete)


agent_tool_calls

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
session_idtextNOT NULL
tool_nametextNOT NULL
inputjsonbNOT NULL default '{}'
outputjsonb
errortext
duration_msinteger
called_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users see their tool calls" ON agent_tool_calls
  FOR SELECT USING (auth.uid() = owner_id);

Indexes: agent_tool_calls_session on (owner_id, session_id, called_at DESC)

Services: AgentMemoryService (insert)


Migration 00011 -- Privacy

retention_policies

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
nametextNOT NULL
descriptiontext
target_tabletextNOT NULL
retention_daysintegerNOT NULL default 90
is_activebooleandefault true
last_run_attimestamptz
next_run_attimestamptzdefault now() + interval '1 day'
rows_deletedintegerdefault 0
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users manage their retention policies" ON retention_policies
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • retention_policies_owner on (owner_id, is_active)
  • retention_policies_next_run on (next_run_at) WHERE is_active = true

Services: AuditService (query), PrivacyService


ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
purposetextNOT NULL
grantedbooleanNOT NULL default false
granted_attimestamptz
revoked_attimestamptz
expires_attimestamptz
metadatajsonbdefault '{}'
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

Unique: (owner_id, purpose)

RLS: Enabled.

CREATE POLICY "users manage their consent records" ON consent_records
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: consent_records_owner on (owner_id, purpose)

Services: AuditService (query), PrivacyService


pii_scan_log

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
entity_typetextNOT NULL
entity_idtextNOT NULL
pii_types_foundtext[]default '{}'
was_redactedbooleandefault false
scanned_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users see their pii scan log" ON pii_scan_log
  FOR SELECT USING (auth.uid() = owner_id);

Indexes: pii_scan_log_owner on (owner_id, scanned_at DESC)

Services: PrivacyService


Migration 00012 -- Notifications

notification_subscriptions

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
subscription_typetextNOT NULL, CHECK IN ('web_push','fcm','apns')
endpointtextNOT NULL
auth_keytext
p256dh_keytext
device_nametext
is_activebooleandefault true
last_used_attimestamptz
created_attimestamptzdefault now()

Unique: (owner_id, endpoint)

RLS: Enabled.

CREATE POLICY "users manage their notification subscriptions" ON notification_subscriptions
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: notif_subs_owner on (owner_id, is_active)

Services: NotificationService (CRUD, delete)


outbound_webhooks

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
nametextNOT NULL
urltextNOT NULL
secrettext
event_typestext[]NOT NULL default '{}'
is_activebooleandefault true
failure_countintegerdefault 0
last_triggeredtimestamptz
last_successtimestamptz
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users manage their webhooks" ON outbound_webhooks
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: outbound_webhooks_owner on (owner_id, is_active)

Services: OutboundWebhookService (CRUD, delete)


webhook_delivery_log

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
webhook_iduuidNOT NULL, FK outbound_webhooks(id) ON DELETE CASCADE
event_typetextNOT NULL
payloadjsonbNOT NULL
response_statusinteger
response_bodytext
duration_msinteger
successbooleandefault false
errortext
delivered_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users see their webhook logs" ON webhook_delivery_log
  FOR SELECT USING (EXISTS (SELECT 1 FROM outbound_webhooks WHERE id = webhook_id AND owner_id = auth.uid()));

Indexes: webhook_log_webhook on (webhook_id, delivered_at DESC)

Foreign Keys: webhook_id -> outbound_webhooks(id) ON DELETE CASCADE

Services: OutboundWebhookService


Migration 00013 -- Presence

user_presence

ColumnTypeConstraints
owner_iduuidPK, FK auth.users(id)
statustextNOT NULL default 'offline', CHECK IN ('online','away','busy','offline')
activitytext
last_seen_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users manage their own presence" ON user_presence
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);
CREATE POLICY "anyone can read presence" ON user_presence FOR SELECT USING (true);

Services: PresenceService, ScheduledJobService (stale presence cleanup)


collaboration_sessions

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
session_typetextNOT NULL default 'document', CHECK IN ('document','rule_edit','dao_vote','marketplace_review')
entity_idtext
titletextNOT NULL
participantsuuid[]default '{}'
is_activebooleandefault true
started_attimestamptzdefault now()
ended_attimestamptz
metadatajsonbdefault '{}'

RLS: Enabled.

CREATE POLICY "participants can see sessions" ON collaboration_sessions
  FOR SELECT USING (auth.uid() = owner_id OR auth.uid() = ANY(participants));
CREATE POLICY "owners manage sessions" ON collaboration_sessions
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • collab_sessions_owner on (owner_id, is_active)
  • collab_sessions_entity on (entity_id, session_type)

Services: CollaborationService


collaboration_cursors

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
session_iduuidNOT NULL, FK collaboration_sessions(id) ON DELETE CASCADE
user_iduuidNOT NULL, FK auth.users(id)
positionjsonbNOT NULL default '{}'
selectionjsonb
colortext
labeltext
updated_attimestamptzdefault now()

Unique: (session_id, user_id)

RLS: Enabled.

CREATE POLICY "participants see cursors" ON collaboration_cursors FOR SELECT
  USING (EXISTS (SELECT 1 FROM collaboration_sessions s WHERE s.id = session_id AND (s.owner_id = auth.uid() OR auth.uid() = ANY(s.participants))));
CREATE POLICY "users own their cursor" ON collaboration_cursors
  USING (auth.uid() = user_id) WITH CHECK (auth.uid() = user_id);

Indexes: collab_cursors_session on (session_id, updated_at DESC)

Foreign Keys: session_id -> collaboration_sessions(id) ON DELETE CASCADE

Services: CollaborationService


Migration 00014 -- Audit

compliance_reports

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
report_typetextNOT NULL, CHECK IN ('gdpr_access','gdpr_erasure','data_export','access_summary','consent_history','retention_summary')
statustextNOT NULL default 'pending', CHECK IN ('pending','generating','completed','failed')
parametersjsonbdefault '{}'
result_urltext
result_size_kbinteger
errortext
generated_attimestamptz
expires_attimestamptzdefault now() + interval '7 days'
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their compliance reports" ON compliance_reports
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: compliance_reports_owner on (owner_id, created_at DESC)

Services: AuditService


audit_alert_rules

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
nametextNOT NULL
descriptiontext
event_typetext
thresholdintegerdefault 10
window_minutesintegerdefault 60
is_activebooleandefault true
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users manage their alert rules" ON audit_alert_rules
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Services: AuditService (CRUD, delete)


Migration 00015 -- Plugins

plugin_registry

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
plugin_idtextNOT NULL UNIQUE
nametextNOT NULL
descriptiontext
versiontextNOT NULL default '1.0.0'
plugin_typetextNOT NULL, CHECK IN ('connector','channel','rule_operator','ai_tool','data_processor')
authortext
icon_urltext
permissionsjsonbdefault '[]'
required_credentialstext[]default '{}'
optional_credentialstext[]default '{}'
capabilitiestext[]default '{}'
is_builtinbooleandefault false
is_activebooleandefault true
install_countintegerdefault 0
rating_avgnumeric(3,2)default 0
rating_countintegerdefault 0
manifestjsonbdefault '{}'
owner_iduuidFK auth.users(id) (nullable)
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "anyone can read active plugins" ON plugin_registry
  FOR SELECT USING (is_active = true);

Indexes: plugin_registry_type on (plugin_type, is_active)

Services: PluginRegistryService, PluginManager


user_plugins

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
plugin_idtextNOT NULL, FK plugin_registry(plugin_id)
is_enabledbooleandefault true
configjsonbdefault '{}'
installed_attimestamptzdefault now()
last_used_attimestamptz

Unique: (owner_id, plugin_id)

RLS: Enabled.

CREATE POLICY "users manage their plugins" ON user_plugins
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: user_plugins_owner on (owner_id, is_enabled)

Foreign Keys: plugin_id -> plugin_registry(plugin_id)

Services: PluginRegistryService (install/uninstall/delete)


plugin_ratings

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
plugin_idtextNOT NULL, FK plugin_registry(plugin_id)
ratingintegerNOT NULL, CHECK BETWEEN 1 AND 5
reviewtext
created_attimestamptzdefault now()

Unique: (owner_id, plugin_id)

RLS: Enabled.

CREATE POLICY "users manage their ratings" ON plugin_ratings
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);
CREATE POLICY "anyone can read ratings" ON plugin_ratings FOR SELECT USING (true);

Foreign Keys: plugin_id -> plugin_registry(plugin_id)

Services: PluginRegistryService


Migration 00016 -- Documents

document_jobs

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
document_idtextNOT NULL
job_typetextNOT NULL, CHECK IN ('extract','summarize','classify','extract_entities','chunk','embed')
statustextNOT NULL default 'pending', CHECK IN ('pending','processing','completed','failed')
resultjsonb
errortext
started_attimestamptz
completed_attimestamptz
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their document jobs" ON document_jobs
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • doc_jobs_owner on (owner_id, status, created_at DESC)
  • doc_jobs_document on (document_id, job_type)

Services: DocumentIntelligenceService


document_chunks

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
document_idtextNOT NULL
chunk_indexintegerNOT NULL
contenttextNOT NULL
token_countinteger
metadatajsonbdefault '{}'
created_attimestamptzdefault now()

Unique: (owner_id, document_id, chunk_index)

RLS: Enabled.

CREATE POLICY "users own their document chunks" ON document_chunks
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: doc_chunks_document on (owner_id, document_id, chunk_index)

Services: DocumentIntelligenceService, RAGService


document_entities

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
document_idtextNOT NULL
entity_typetextNOT NULL
entity_valuetextNOT NULL
confidencenumeric(4,3)default 1.0
contexttext
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their entities" ON document_entities
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • doc_entities_document on (owner_id, document_id)
  • doc_entities_type on (owner_id, entity_type)

Services: DocumentIntelligenceService


Migration 00017 -- Rules

rule_templates

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
nametextNOT NULL
descriptiontext
categorytextNOT NULL default 'general', CHECK IN ('communication','schedule','location','automation','governance','privacy')
condition_astjsonbNOT NULL
actionsjsonbNOT NULL default '[]'
tagstext[]default '{}'
use_countintegerdefault 0
is_featuredbooleandefault false
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "anyone can read templates" ON rule_templates FOR SELECT USING (true);

Indexes: rule_templates_category on (category, is_featured)

Services: RulesService (template queries)


rule_execution_log

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
rule_idtextNOT NULL
triggered_bytextNOT NULL
matchedbooleanNOT NULL
actions_firedintegerdefault 0
execution_msinteger
errortext
context_snapshotjsonbdefault '{}'
fired_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their rule executions" ON rule_execution_log
  FOR SELECT USING (auth.uid() = owner_id);

Indexes:

  • rule_exec_owner on (owner_id, fired_at DESC)
  • rule_exec_rule on (rule_id, fired_at DESC)

Services: RulesService (insert after evaluation)


Migration 00018 -- Scheduled Jobs

No tables created. Enables pg_cron extension and schedules five recurring jobs. See Scheduled Jobs above.


Migration 00019 -- Rate Limits

rate_limit_events

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuid
policytextNOT NULL
keytextNOT NULL
allowedbooleanNOT NULL
remainingintegerNOT NULL
created_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes:

  • (owner_id, created_at DESC)
  • (policy, created_at DESC)

Services: RateLimiterService


circuit_breaker_snapshots

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
circuit_nametextNOT NULL
statetextNOT NULL, CHECK IN ('CLOSED', 'OPEN', 'HALF_OPEN')
failuresintegerNOT NULL default 0
recorded_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes: (circuit_name, recorded_at DESC)

Services: CircuitBreakerService


Migration 00020 -- Event Store

event_store

Append-only event sourcing store.

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
stream_idtextNOT NULL
event_typetextNOT NULL
payloadjsonbNOT NULL default '{}'
versionintegerNOT NULL
correlation_iduuid
causation_iduuid
metadatajsonbdefault '{}'
occurred_attimestamptzNOT NULL default now()

Unique: (stream_id, version)

RLS: Not enabled.

Indexes:

  • event_store_stream_version_idx on (stream_id, version)
  • event_store_event_type_idx on (event_type, occurred_at DESC)

Services: EventStoreService


event_snapshots

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
stream_idtextNOT NULL UNIQUE
statejsonbNOT NULL
versionintegerNOT NULL
created_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes: event_snapshots_stream_id_idx on (stream_id)

Services: EventStoreService


Migration 00021 -- Streaming

activity_feed

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL
typetextNOT NULL
titletextNOT NULL
descriptiontextNOT NULL
entity_typetext
entity_iduuid
metadatajsonbdefault '{}'
is_readbooleanNOT NULL default false
occurred_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "activity_feed_owner_policy" ON activity_feed FOR ALL USING (owner_id = auth.uid());

Indexes:

  • activity_feed_owner_time on (owner_id, occurred_at DESC)
  • activity_feed_owner_unread_time on (owner_id, is_read, occurred_at DESC)

Services: ActivityFeedService (CRUD, mark read)


Migration 00022 -- Orgs

Note: The organizations table was created in 00001 and extended here with slug, avatar_url, billing_plan, billing_status columns. See organizations above for the merged schema.

org_memberships

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
org_iduuidNOT NULL, FK organizations(id) ON DELETE CASCADE
user_iduuidNOT NULL, FK auth.users(id)
roletextNOT NULL default 'member', CHECK IN ('owner','admin','member','viewer')
invited_byuuidFK auth.users(id)
joined_attimestamptzNOT NULL default now()

Unique: (org_id, user_id)

RLS: Not enabled (service-role access pattern).

Indexes:

  • (org_id)
  • (user_id)

Foreign Keys: org_id -> organizations(id) ON DELETE CASCADE

Services: OrgService


org_invites

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
org_iduuidNOT NULL, FK organizations(id) ON DELETE CASCADE
emailtextNOT NULL
roletextNOT NULL default 'member'
tokentextNOT NULL UNIQUE, default encode(gen_random_bytes(32), 'hex')
expires_attimestamptzNOT NULL default now() + interval '7 days'
created_byuuidNOT NULL, FK auth.users(id)
created_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes:

  • (org_id)
  • (token)

Foreign Keys: org_id -> organizations(id) ON DELETE CASCADE

Services: OrgService


usage_records

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
org_iduuidNOT NULL, FK organizations(id)
metrictextNOT NULL
valuenumericNOT NULL default 0
period_starttimestamptzNOT NULL
period_endtimestamptzNOT NULL
recorded_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes: (org_id, metric, period_start)

Foreign Keys: org_id -> organizations(id)

Services: BillingService, UsageTrackingService


billing_events

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
org_iduuidNOT NULL, FK organizations(id)
typetextNOT NULL
metadatajsonbNOT NULL default '{}'
occurred_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes: (org_id, occurred_at DESC)

Foreign Keys: org_id -> organizations(id)

Services: BillingService


Migration 00023 -- Developer

oauth_apps

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL
nametextNOT NULL
descriptiontext
client_idtextNOT NULL UNIQUE, default encode(gen_random_bytes(16), 'hex')
client_secret_hashtextNOT NULL
redirect_uristext[]NOT NULL default '{}'
scopestext[]NOT NULL default '{}'
logo_urltext
website_urltext
created_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes:

  • (owner_id)
  • (client_id)

Services: OAuthService


oauth_auth_codes

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
app_iduuidNOT NULL, FK oauth_apps(id) ON DELETE CASCADE
user_iduuidNOT NULL
codetextNOT NULL UNIQUE, default encode(gen_random_bytes(32), 'hex')
scopestext[]NOT NULL default '{}'
redirect_uritextNOT NULL
expires_attimestamptzNOT NULL default now() + interval '10 minutes'
used_attimestamptz
created_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes: (code)

Foreign Keys: app_id -> oauth_apps(id) ON DELETE CASCADE

Services: OAuthService


oauth_tokens

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
app_iduuidNOT NULL, FK oauth_apps(id) ON DELETE CASCADE
user_iduuidNOT NULL
access_tokentextNOT NULL UNIQUE, default encode(gen_random_bytes(32), 'hex')
refresh_tokentextUNIQUE, default encode(gen_random_bytes(32), 'hex')
scopestext[]NOT NULL default '{}'
expires_attimestamptzNOT NULL default now() + interval '1 hour'
revoked_attimestamptz
created_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes:

  • (access_token)
  • (refresh_token)
  • (user_id, app_id)

Foreign Keys: app_id -> oauth_apps(id) ON DELETE CASCADE

Services: OAuthService


api_keys

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL
nametextNOT NULL
key_prefixtextNOT NULL
key_hashtextNOT NULL UNIQUE
scopestext[]NOT NULL default '{}'
statustextNOT NULL default 'active', CHECK IN ('active','revoked','expired')
last_used_attimestamptz
expires_attimestamptz
created_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes:

  • (owner_id)
  • (key_hash)

Services: APIKeyService


saved_searches

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL
nametextNOT NULL
queryjsonbNOT NULL default '{}'
alert_enabledbooleanNOT NULL default false
last_alert_attimestamptz
created_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes: saved_searches_owner_id_idx on (owner_id)

Services: SavedSearchService (CRUD, delete, update)


recommendations

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL
typetextNOT NULL, CHECK IN ('contact','rule_template','capability','content')
entity_idtextNOT NULL
entity_typetextNOT NULL
reasontextNOT NULL
scorenumericNOT NULL default 0
metadatajsonbdefault '{}'
generated_attimestamptzNOT NULL default now()
expires_attimestamptzNOT NULL default now() + interval '24 hours'
dismissedbooleanNOT NULL default false

RLS: Not enabled.

Indexes:

  • recommendations_owner_dismissed_expires_idx on (owner_id, dismissed, expires_at)
  • recommendations_owner_type_idx on (owner_id, type)

Services: RecommendationEngine (CRUD, delete), ScheduledJobService (cleanup expired)


Migration 00025 -- Data Portability

export_jobs

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL
formattextNOT NULL, CHECK IN ('json','csv','vcard','ical','mbox','zip')
entity_typestext[]NOT NULL default '{}'
filtersjsonbdefault '{}'
statustextNOT NULL default 'pending', CHECK IN ('pending','processing','ready','failed','expired')
download_urltext
size_bytesbigint
record_countinteger
errortext
created_attimestamptzNOT NULL default now()
completed_attimestamptz
expires_attimestamptz

RLS: Not enabled.

Indexes:

  • (owner_id, created_at DESC)
  • (status, created_at)

Services: DataPortabilityService


import_jobs

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL
formattextNOT NULL, CHECK IN ('json','csv','vcard','ical')
file_nametextNOT NULL
statustextNOT NULL default 'pending', CHECK IN ('pending','processing','completed','failed')
total_recordsinteger
imported_recordsintegerNOT NULL default 0
failed_recordsintegerNOT NULL default 0
errorsjsonbNOT NULL default '[]'
created_attimestamptzNOT NULL default now()
completed_attimestamptz

RLS: Not enabled.

Indexes: (owner_id, created_at DESC)

Services: DataPortabilityService


Migration 00026 -- Preferences

user_preferences

ColumnTypeConstraints
user_iduuidPK, NOT NULL
color_schemetextNOT NULL default 'system', CHECK IN ('light','dark','system')
localetextNOT NULL default 'en', CHECK IN ('en','es','fr','de','ja','zh')
text_sizetextNOT NULL default 'md', CHECK IN ('sm','md','lg','xl')
contrast_modetextNOT NULL default 'normal', CHECK IN ('normal','high')
reduced_motionbooleanNOT NULL default false
timezonetextNOT NULL default 'UTC'
date_formattextNOT NULL default 'MM/DD/YYYY'
time_formattextNOT NULL default '12h', CHECK IN ('12h','24h')
currencytextNOT NULL default 'USD'
notification_emailbooleanNOT NULL default true
notification_pushbooleanNOT NULL default true
notification_in_appbooleanNOT NULL default true
notification_digesttextNOT NULL default 'none', CHECK IN ('none','daily','weekly')
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "user_preferences_select_own" ON user_preferences FOR SELECT USING (auth.uid() = user_id);
CREATE POLICY "user_preferences_insert_own" ON user_preferences FOR INSERT WITH CHECK (auth.uid() = user_id);
CREATE POLICY "user_preferences_update_own" ON user_preferences FOR UPDATE USING (auth.uid() = user_id) WITH CHECK (auth.uid() = user_id);

Triggers: user_preferences_updated_at BEFORE UPDATE -> update_user_preferences_updated_at()

Services: PreferencesService


Migration 00027 -- Monitoring

tracked_errors

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
fingerprinttextNOT NULL
typetextNOT NULL
messagetextNOT NULL
stacktext
contextjsonbNOT NULL default '{}'
severitytextNOT NULL default 'medium', CHECK IN ('low','medium','high','critical')
countintegerNOT NULL default 1
first_seen_attimestamptzNOT NULL default now()
last_seen_attimestamptzNOT NULL default now()
resolvedbooleanNOT NULL default false

RLS: Not enabled.

Indexes:

  • tracked_errors_fingerprint_idx on (fingerprint)
  • tracked_errors_severity_resolved_idx on (severity, resolved, last_seen_at DESC)
  • tracked_errors_resolved_idx on (resolved, last_seen_at DESC)

Services: ErrorTrackingService


email_queue

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
to_addresstextNOT NULL
from_addresstextNOT NULL default 'noreply@made-open.app'
subjecttextNOT NULL
html_bodytextNOT NULL
text_bodytext
template_idtext
template_varsjsonbdefault '{}'
statustextNOT NULL default 'pending', CHECK IN ('pending','sent','failed','bounced')
attemptsintegerNOT NULL default 0
last_errortext
scheduled_attimestamptzNOT NULL default now()
sent_attimestamptz
created_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes:

  • email_queue_status_scheduled_idx on (status, scheduled_at)
  • email_queue_to_address_created_idx on (to_address, created_at DESC)

Services: EmailQueueService


Migration 00028 -- Billing

stripe_customers

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
org_iduuidNOT NULL, FK organizations(id) ON DELETE CASCADE, UNIQUE
stripe_customer_idtextNOT NULL UNIQUE
stripe_subscription_idtextUNIQUE
stripe_price_idtext
subscription_statustextCHECK IN ('active','trialing','past_due','canceled','unpaid')
current_period_starttimestamptz
current_period_endtimestamptz
cancel_at_period_endbooleanNOT NULL default false
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes:

  • (stripe_customer_id)
  • (org_id)

Foreign Keys: org_id -> organizations(id) ON DELETE CASCADE

Services: BillingService


checkout_sessions

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
org_iduuidNOT NULL, FK organizations(id)
price_idtextNOT NULL
success_urltextNOT NULL
cancel_urltextNOT NULL
session_idtextNOT NULL UNIQUE
urltextNOT NULL
expires_attimestamptzNOT NULL
created_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes: (session_id)

Foreign Keys: org_id -> organizations(id)

Services: BillingService


feature_flags

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
nametextNOT NULL UNIQUE
descriptiontextNOT NULL default ''
enabledbooleanNOT NULL default false
rollout_percentageintegerNOT NULL default 0, CHECK BETWEEN 0 AND 100
enabled_for_orgstext[]NOT NULL default '{}'
enabled_for_planstext[]NOT NULL default '{}'
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes: (name)

Services: FeatureFlagService


Migration 00029 -- Security

user_sessions

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
user_iduuidNOT NULL
user_agenttext
ip_addresstext
last_active_attimestamptzNOT NULL default now()
expires_attimestamptzNOT NULL default now() + interval '30 days'
revoked_attimestamptz
created_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes: user_sessions_user_revoked_expires_idx on (user_id, revoked_at, expires_at)

Services: SessionService


analytics_events

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuid
event_typetextNOT NULL
propertiesjsonbNOT NULL default '{}'
session_iduuid
occurred_attimestamptzNOT NULL default now()

RLS: Not enabled.

Indexes:

  • analytics_events_owner_type_time_idx on (owner_id, event_type, occurred_at DESC)
  • analytics_events_type_time_idx on (event_type, occurred_at DESC)

Services: AnalyticsService


Migration 00030 -- Lineage

entity_lineage

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
entity_typetextNOT NULL
entity_iduuidNOT NULL
owner_iduuidNOT NULL
fieldsjsonbNOT NULL default '[]'
merged_from_idsuuid[]NOT NULL default '{}'
primary_sourcetextNOT NULL default 'manual'
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

Unique: (entity_type, entity_id)

RLS: Not enabled.

Indexes:

  • (owner_id, entity_type)
  • (entity_id)

Services: EntityMergeService, LineageService


merge_candidates

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
entity_typetextNOT NULL
entity_a_iduuidNOT NULL
entity_b_iduuidNOT NULL
confidencenumericNOT NULL default 0
match_reasonstext[]NOT NULL default '{}'
statustextNOT NULL default 'pending', CHECK IN ('pending','merged','rejected')
created_attimestamptzNOT NULL default now()
resolved_attimestamptz

Unique: (entity_type, entity_a_id, entity_b_id)

RLS: Not enabled.

Indexes:

  • (status, confidence DESC)
  • (entity_a_id)
  • (entity_b_id)

Services: EntityMergeService


conflict_resolution_rules

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
fieldtextNOT NULL UNIQUE
strategytextNOT NULL default 'newest', CHECK IN ('newest','oldest','highest_confidence','source_priority','manual')
source_prioritytext[]NOT NULL default '{}'
created_attimestamptzNOT NULL default now()

RLS: Not enabled.

Services: EntityMergeService


Migration 00031 -- Credential Wallet

user_credentials

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
credential_typetextNOT NULL
display_infotext
is_activebooleandefault true
vault_keystext[]NOT NULL default '{}'
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

Unique: (owner_id, credential_type)

RLS: Enabled.

CREATE POLICY "users own their credentials" ON user_credentials
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: (owner_id)

Services: CredentialWalletService, CapabilityRegistry, PluginManager


Migration 00032 -- Tools

tool_jobs

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
operationtextNOT NULL
categorytextNOT NULL, CHECK IN ('pdf','image','audio','video','document','font','archive','data','qrcode','crypto','text','color','svg','code','math','regex','datetime','markdown','validate','jwt','html','generate','cron','geo','network','diff','template','ai')
statustextNOT NULL default 'pending', CHECK IN ('pending','processing','completed','failed','cancelled')
prioritytextNOT NULL default 'interactive', CHECK IN ('realtime','interactive','background')
input_pathsjsonbNOT NULL default '[]'
output_pathsjsonbNOT NULL default '[]'
paramsjsonbNOT NULL default '{}'
resultjsonb
errortext
progressintegerdefault 0, CHECK >= 0 AND <= 100
callback_urltext
started_attimestamptz
completed_attimestamptz
created_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their tool jobs" ON tool_jobs
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • tool_jobs_owner_status on (owner_id, status, created_at DESC)
  • tool_jobs_category on (category, status)
  • tool_jobs_pending on (status, priority, created_at) WHERE status = 'pending'

Services: ToolsService


fonts

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
nametextNOT NULL
familytextNOT NULL
styletextNOT NULL default 'normal', CHECK IN ('normal','italic','oblique')
weightintegerNOT NULL default 400
storage_pathtextNOT NULL
formattextNOT NULL, CHECK IN ('ttf','otf','woff','woff2')
metadatajsonbdefault '{}'
preview_urltext
created_attimestamptzdefault now()

Unique: (owner_id, family, style, weight)

RLS: Enabled.

CREATE POLICY "users own their fonts" ON fonts
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: fonts_owner on (owner_id, family)

Services: ToolsService (CRUD, delete)


Migration 00033 -- Audio Intelligence

audio_sessions

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
sourcetextNOT NULL, CHECK IN ('microphone','system','both')
statustextNOT NULL default 'recording', CHECK IN ('recording','paused','completed','processing')
device_idtext
audio_storage_pathtext
duration_secondsnumeric(10,2)
session_typetextCHECK IN ('manual','continuous','meeting') (added 00034)
ended_reasontextCHECK IN ('user_stop','rotation','silence_gap','crash_recovery','app_exit') (added 00034)
started_attimestamptzNOT NULL default now()
ended_attimestamptz
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their audio sessions" ON audio_sessions
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • audio_sessions_owner_status on (owner_id, status, started_at DESC)
  • audio_sessions_device on (owner_id, device_id, started_at DESC)

Triggers: audio_sessions_updated_at BEFORE UPDATE -> set_updated_at()

Services: AudioETLService, AlwaysOnAudioService


transcripts

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
session_iduuidNOT NULL, FK audio_sessions(id) ON DELETE CASCADE
segmentsjsonbNOT NULL default '[]'
full_texttextNOT NULL default ''
modeltextNOT NULL
passsmallintNOT NULL, CHECK IN (1,2,3)
avg_confidencenumeric(4,3)
contextjsonb(added 00034)
created_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their transcripts" ON transcripts
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • transcripts_session on (session_id, pass)
  • transcripts_owner_created on (owner_id, created_at DESC)
  • transcripts_fulltext using GIN on to_tsvector('english', full_text)

Foreign Keys: session_id -> audio_sessions(id) ON DELETE CASCADE

Services: AudioETLService, TranscriptionService


voice_commands

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
session_iduuidNOT NULL, FK audio_sessions(id) ON DELETE CASCADE
raw_transcripttextNOT NULL
command_texttextNOT NULL
intenttextNOT NULL
confidencenumeric(4,3)
resolved_contactjsonb
paramsjsonbNOT NULL default '{}'
job_idtext
statustextNOT NULL default 'queued', CHECK IN ('queued','processing','completed','failed','disambiguation-needed')
errortext
disambiguation_sentbooleanNOT NULL default false
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their voice commands" ON voice_commands
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • voice_commands_owner_status on (owner_id, status, created_at DESC)
  • voice_commands_session on (session_id)
  • voice_commands_intent on (owner_id, intent, created_at DESC)

Triggers: voice_commands_updated_at BEFORE UPDATE -> set_updated_at()

Foreign Keys: session_id -> audio_sessions(id) ON DELETE CASCADE

Services: VoiceCommandService, AudioETLService


extracted_intelligence

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
session_iduuidNOT NULL, FK audio_sessions(id) ON DELETE CASCADE
transcript_iduuidNOT NULL, FK transcripts(id) ON DELETE CASCADE
typetextNOT NULL, CHECK IN ('action-item','decision','commitment','question','deadline','idea','problem','follow-up','entity-mention','topic')
contenttextNOT NULL
source_texttext
offset_msinteger
mentioned_person_idsjsonbNOT NULL default '[]'
task_iduuid
event_iduuid
confidencenumeric(4,3)
created_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their extracted intelligence" ON extracted_intelligence
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • extracted_intelligence_session on (session_id, type)
  • extracted_intelligence_owner_type on (owner_id, type, created_at DESC)

Foreign Keys: session_id -> audio_sessions(id), transcript_id -> transcripts(id) ON DELETE CASCADE

Services: AudioETLService


daily_briefs

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
datedateNOT NULL
session_countintegerNOT NULL default 0
total_audio_secondsnumeric(12,2)NOT NULL default 0
summarytextNOT NULL default ''
statsjsonbNOT NULL default '{}'
recurring_topicsjsonbNOT NULL default '[]'
unresolved_questionsjsonbNOT NULL default '[]'
created_attimestamptzNOT NULL default now()

Unique: (owner_id, date)

RLS: Enabled.

CREATE POLICY "users own their daily briefs" ON daily_briefs
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: daily_briefs_owner_date on (owner_id, date DESC)

Services: AudioETLService, DailyBriefService


Migration 00034 -- Always-On Audio

context_snapshots

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
hashtextNOT NULL
contextjsonbNOT NULL
created_attimestamptzNOT NULL default now()

Unique: (owner_id, hash)

RLS: Enabled.

CREATE POLICY "users own their context snapshots" ON context_snapshots
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: context_snapshots_owner_hash on (owner_id, hash)

Services: AlwaysOnAudioService


transcript_chunks

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
session_iduuidNOT NULL, FK audio_sessions(id) ON DELETE CASCADE
full_texttextNOT NULL default ''
offset_msintegerNOT NULL default 0
duration_msintegerNOT NULL default 0
context_hashtext
modeltext
created_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their transcript chunks" ON transcript_chunks
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • transcript_chunks_fulltext using GIN on to_tsvector('english', full_text)
  • transcript_chunks_session on (session_id, created_at)
  • transcript_chunks_owner_created on (owner_id, created_at DESC)

Foreign Keys: session_id -> audio_sessions(id) ON DELETE CASCADE

Services: AlwaysOnAudioService


passive_intents

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
session_iduuidNOT NULL, FK audio_sessions(id) ON DELETE CASCADE
texttextNOT NULL
intent_typetextNOT NULL, CHECK IN ('reminder','follow-up','delegation','save-context','bookmark','question')
confidencenumeric(4,3)NOT NULL
contextjsonb
confirmedbooleanNOT NULL default false
acted_onbooleanNOT NULL default false
created_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their passive intents" ON passive_intents
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • passive_intents_owner on (owner_id, confirmed, created_at DESC)
  • passive_intents_session on (session_id)

Foreign Keys: session_id -> audio_sessions(id) ON DELETE CASCADE

Services: AlwaysOnAudioService


Migration 00035 -- Device Commands

device_commands

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
device_idtextNOT NULL
owner_iduuidNOT NULL, FK auth.users(id)
moduletextNOT NULL, CHECK IN ('filesystem','process','clipboard','display','power','network','registry','notifications','input','shell','agent') (expanded in 00036)
actiontextNOT NULL
paramsjsonbNOT NULL default '{}'
statustextNOT NULL default 'pending', CHECK IN ('pending','sent','received','executing','completed','failed','rejected','expired')
prioritytextNOT NULL default 'interactive', CHECK IN ('realtime','interactive','background')
sourcetextNOT NULL default 'api', CHECK IN ('voice-command','web-ui','rules-engine','api','agent-worker') (expanded in 00036)
source_command_idtext
resultjsonb
errortext
progressjsonbNOT NULL default '[]' (added 00036)
created_attimestamptzNOT NULL default now()
sent_attimestamptz
received_attimestamptz
completed_attimestamptz
expires_attimestamptz

Constraint: valid_module_action -- validates module+action combinations (see migration 00035/00036 for full matrix).

RLS: Enabled.

CREATE POLICY "users own their device commands" ON device_commands
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • device_commands_pending on (device_id, status, created_at) WHERE status = 'pending'
  • device_commands_owner on (owner_id, created_at DESC)
  • device_commands_expires on (expires_at) WHERE status IN ('pending', 'sent') AND expires_at IS NOT NULL
  • device_commands_agent_pending on (device_id, status, created_at) WHERE module = 'agent' AND status = 'pending' (00036)

Supabase Realtime: Table is added to supabase_realtime publication.

Services: DeviceCommandService, AgentWorkerService


Migration 00036 -- Agent Worker

No new tables. Extends device_commands with:

  • agent module and agent-worker source (constraint updates)
  • progress JSONB column
  • append_command_progress() RPC function
  • Agent-specific pending index

Migration 00037 -- LLM Routing Rules

llm_routing_rules

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
nametextNOT NULL
priorityintegerNOT NULL default 100
enabledbooleanNOT NULL default true
data_domainstext[]default '{}'
query_typestext[]default '{}'
providertextNOT NULL, CHECK IN ('openrouter', 'ollama')
modeltext
reasontext
created_attimestamptzdefault now()
updated_attimestamptzdefault now()

RLS: Enabled.

CREATE POLICY "users own their routing rules" ON llm_routing_rules
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: llm_routing_rules_owner on (owner_id, priority)

Services: LLMRoutingService


Migration 00038 -- Unified Scheduler

schedules

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidFK auth.users(id) ON DELETE CASCADE (nullable for system schedules)
nametextNOT NULL
descriptiontext
schedule_typetextNOT NULL, CHECK IN ('one_shot', 'recurring')
cron_expressiontext
rruletext
trigger_attimestamptz
delay_msbigint
payloadjsonbNOT NULL default '{}'
statustextNOT NULL default 'active', CHECK IN ('active', 'paused', 'completed', 'failed', 'cancelled')
source_typetextNOT NULL default 'custom', CHECK IN ('system', 'rule', 'workflow', 'intention', 'connector', 'custom')
source_idtext
boss_job_idtext
boss_schedule_nametext
last_run_attimestamptz
next_run_attimestamptz
run_countintegerNOT NULL default 0
error_countintegerNOT NULL default 0
last_errortext
timezonetextNOT NULL default 'UTC'
idempotency_keytextUNIQUE
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users_own_schedules" ON schedules
  USING (owner_id IS NULL OR auth.uid() = owner_id)
  WITH CHECK (owner_id IS NULL OR auth.uid() = owner_id);

Indexes:

  • idx_schedules_owner_status on (owner_id, status)
  • idx_schedules_source on (source_type, source_id)
  • idx_schedules_next_run on (next_run_at) WHERE status = 'active'
  • idx_schedules_boss_schedule on (boss_schedule_name) WHERE boss_schedule_name IS NOT NULL

Triggers: trg_schedules_updated_at BEFORE UPDATE -> update_schedules_updated_at()

Services: SchedulerService (full CRUD, cancel, pause, resume, run tracking)


schedule_runs

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
schedule_iduuidNOT NULL, FK schedules(id) ON DELETE CASCADE
owner_iduuidFK auth.users(id) ON DELETE SET NULL
statustextNOT NULL, CHECK IN ('started', 'completed', 'failed')
started_attimestamptzNOT NULL default now()
completed_attimestamptz
duration_msinteger
errortext
resultjsonb
created_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users_own_schedule_runs" ON schedule_runs
  USING (owner_id IS NULL OR auth.uid() = owner_id)
  WITH CHECK (owner_id IS NULL OR auth.uid() = owner_id);

Indexes:

  • idx_schedule_runs_schedule on (schedule_id, started_at DESC)
  • idx_schedule_runs_owner on (owner_id, started_at DESC)

Foreign Keys: schedule_id -> schedules(id) ON DELETE CASCADE

Services: SchedulerService (insert/update)


Migration 00039 -- RLS Hardening

No new tables. Adds owner_id and RLS to attachments and location_history, and adds WITH CHECK to 11 tables that previously only had USING:

  • organizations, channels, conversations, messages, events, locations, devices, tasks, documents, rules, embeddings

Migration 00040 -- Wiki

wiki_pages

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id)
slugtextNOT NULL
titletextNOT NULL
page_typetextNOT NULL, CHECK IN ('entity', 'concept', 'summary', 'comparison', 'source', 'index', 'log')
contenttextNOT NULL default ''
frontmatterjsonbNOT NULL default '{}'
source_idsuuid[]NOT NULL default '{}'
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

Unique: (owner_id, slug)

RLS: Enabled.

CREATE POLICY "users own their wiki pages" ON wiki_pages
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_wiki_pages_owner on (owner_id)
  • idx_wiki_pages_type on (owner_id, page_type)
  • idx_wiki_pages_frontmatter using GIN on (frontmatter)

Services: WikiService (CRUD, log page updates)


ColumnTypeConstraints
from_page_iduuidNOT NULL, FK wiki_pages(id) ON DELETE CASCADE
to_page_iduuidNOT NULL, FK wiki_pages(id) ON DELETE CASCADE
link_typetextNOT NULL, CHECK IN ('reference', 'related', 'contradicts', 'supersedes')
created_attimestamptzNOT NULL default now()

Primary Key: (from_page_id, to_page_id, link_type)

RLS: Enabled.

CREATE POLICY "users see links from their pages" ON wiki_links
  USING (EXISTS (SELECT 1 FROM wiki_pages WHERE wiki_pages.id = wiki_links.from_page_id AND wiki_pages.owner_id = auth.uid()))
  WITH CHECK (EXISTS (SELECT 1 FROM wiki_pages WHERE wiki_pages.id = wiki_links.from_page_id AND wiki_pages.owner_id = auth.uid()));

Indexes:

  • idx_wiki_links_from on (from_page_id)
  • idx_wiki_links_to on (to_page_id)

Foreign Keys: from_page_id -> wiki_pages(id) ON DELETE CASCADE, to_page_id -> wiki_pages(id) ON DELETE CASCADE

Services: WikiService


Migration 00041 -- Inventory

inventory_items

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
parent_item_iduuidFK inventory_items(id) ON DELETE SET NULL
item_typetextNOT NULL, CHECK IN ('property','vehicle','appliance','electronics','furniture','tool','clothing','collectible','other')
nametextNOT NULL
descriptiontext
brandtext
modeltext
serial_numbertext
statustextNOT NULL default 'active', CHECK IN ('wishlist','purchased','active','in_repair','in_warranty','disposing','gone')
purchase_datedate
purchase_pricenumeric(12,2)
purchase_locationtext
purchase_urltext
warranty_expirydate
expected_lifespan_monthsinteger
disposition_typetextCHECK IN ('sell','give_away','trash','recycle','donate')
disposition_datetimestamptz
location_iduuidFK locations(id) ON DELETE SET NULL
space_iduuidFK inventory_spaces(id) ON DELETE SET NULL
categoriestext[]NOT NULL default '{}'
attributesjsonbNOT NULL default '{}'
mediajsonbNOT NULL default '[]'
metadatajsonbNOT NULL default '{}'
tagstext[]NOT NULL default '{}'
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their inventory items" ON inventory_items
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_inventory_items_owner_status on (owner_id, status)
  • idx_inventory_items_owner_type on (owner_id, item_type)
  • idx_inventory_items_parent on (parent_item_id)
  • idx_inventory_items_owner_created on (owner_id, created_at DESC)
  • idx_inventory_items_location on (location_id)
  • idx_inventory_items_categories using GIN on (categories)
  • idx_inventory_items_tags using GIN on (tags)

Foreign Keys: parent_item_id -> inventory_items(id), location_id -> locations(id), space_id -> inventory_spaces(id)

Triggers: set_inventory_items_updated_at BEFORE UPDATE -> trigger_set_updated_at()

Services: InventoryService (CRUD, status update, event logging)


inventory_spaces

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
property_item_iduuidNOT NULL, FK inventory_items(id) ON DELETE CASCADE
nametextNOT NULL
parent_space_iduuidFK inventory_spaces(id) ON DELETE SET NULL
metadatajsonbNOT NULL default '{}'
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their inventory spaces" ON inventory_spaces
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_inventory_spaces_owner_property on (owner_id, property_item_id)
  • idx_inventory_spaces_parent on (parent_space_id)

Foreign Keys: property_item_id -> inventory_items(id) ON DELETE CASCADE, parent_space_id -> inventory_spaces(id) ON DELETE SET NULL

Triggers: set_inventory_spaces_updated_at BEFORE UPDATE -> trigger_set_updated_at()

Services: InventoryService


inventory_maintenance

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
item_iduuidNOT NULL, FK inventory_items(id) ON DELETE CASCADE
titletextNOT NULL
descriptiontext
statustextNOT NULL default 'scheduled', CHECK IN ('scheduled','overdue','in_progress','completed','skipped')
schedule_typetextNOT NULL default 'one_time', CHECK IN ('one_time','recurring')
recurrence_ruletext
next_due_datedate
last_completed_datedate
costnumeric(12,2)
providertext
notestext
metadatajsonbNOT NULL default '{}'
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their inventory maintenance" ON inventory_maintenance
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_inventory_maintenance_owner_item on (owner_id, item_id)
  • idx_inventory_maintenance_owner_status_due on (owner_id, status, next_due_date)

Foreign Keys: item_id -> inventory_items(id) ON DELETE CASCADE

Triggers: set_inventory_maintenance_updated_at BEFORE UPDATE -> trigger_set_updated_at()

Services: InventoryService (update)


inventory_events

Append-only ledger. UPDATE and DELETE are blocked by trigger.

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
item_iduuidNOT NULL, FK inventory_items(id) ON DELETE CASCADE
event_typetextNOT NULL, CHECK IN ('purchased','moved','repaired','warranty_claimed','status_changed','value_updated','photo_added','document_attached','disposed')
datajsonbNOT NULL default '{}'
occurred_attimestamptzNOT NULL default now()
created_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their inventory events" ON inventory_events
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: idx_inventory_events_owner_item_occurred on (owner_id, item_id, occurred_at DESC)

Triggers:

  • inventory_events_no_update BEFORE UPDATE -> prevent_inventory_event_mutation() (raises exception)
  • inventory_events_no_delete BEFORE DELETE -> prevent_inventory_event_mutation() (raises exception)

Foreign Keys: item_id -> inventory_items(id) ON DELETE CASCADE

Services: InventoryService (insert)


Migration 00042 -- Deep Comms

inbox_items

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
typetextNOT NULL, CHECK IN ('call','sms','email','video','calendar_event','voicemail')
conversation_iduuidFK conversations(id) ON DELETE SET NULL
contact_iduuidFK persons(id) ON DELETE SET NULL
channel_typetextNOT NULL, CHECK IN ('twilio_voice','twilio_sms','ms_graph_email','twilio_video')
directiontextNOT NULL, CHECK IN ('inbound','outbound')
subjecttext
previewtext
timestamptimestamptzNOT NULL default now()
readbooleanNOT NULL default false
starredbooleanNOT NULL default false
archivedbooleanNOT NULL default false
source_tabletext
source_iduuid
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their inbox items" ON inbox_items
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_inbox_items_owner_timestamp on (owner_id, timestamp DESC)
  • idx_inbox_items_owner_read_timestamp on (owner_id, read, timestamp DESC)
  • idx_inbox_items_owner_contact_timestamp on (owner_id, contact_id, timestamp DESC)

Foreign Keys: conversation_id -> conversations(id), contact_id -> persons(id)

Triggers: set_inbox_items_updated_at BEFORE UPDATE -> trigger_set_updated_at()

Services: InboxService (CRUD, mark read, star, archive), ContactTimelineService (update contact_id on merge)


Migration 00043 -- Deep Voice

phone_lines

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
phone_numbertextNOT NULL
twilio_sidtext
labeltextNOT NULL default 'Main'
settingsjsonbNOT NULL default '{}'
is_defaultbooleanNOT NULL default false
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their phone lines" ON phone_lines
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_phone_lines_owner on (owner_id)
  • idx_phone_lines_owner_number UNIQUE on (owner_id, phone_number)

Triggers: set_phone_lines_updated_at BEFORE UPDATE -> trigger_set_updated_at()

Services: PhoneLineService


voicemails

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
call_session_iduuid
phone_line_iduuidFK phone_lines(id) ON DELETE SET NULL
from_numbertextNOT NULL
contact_iduuid
recording_urltextNOT NULL
recording_sidtext
transcriptiontext
duration_secondsinteger
listenedbooleanNOT NULL default false
created_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their voicemails" ON voicemails
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_voicemails_owner_created on (owner_id, created_at DESC)
  • idx_voicemails_owner_listened on (owner_id, listened, created_at DESC)

Foreign Keys: phone_line_id -> phone_lines(id) ON DELETE SET NULL

Services: VoicemailService


call_recordings

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
call_session_iduuidNOT NULL
recording_sidtextNOT NULL
urltextNOT NULL
duration_secondsinteger
created_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their call recordings" ON call_recordings
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_call_recordings_owner on (owner_id)
  • idx_call_recordings_session on (call_session_id)

Services: PhoneLineService, TranscriptionService


call_transcripts

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
call_session_iduuidNOT NULL
segmentsjsonbNOT NULL default '[]'
full_texttextNOT NULL default ''
providertextNOT NULL default 'whisper'
created_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their call transcripts" ON call_transcripts
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_call_transcripts_session on (call_session_id)
  • idx_call_transcripts_owner on (owner_id)

Services: TranscriptionService


call_analyses

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
call_session_iduuidNOT NULL
transcript_iduuidFK call_transcripts(id) ON DELETE SET NULL
summarytext
action_itemsjsonbNOT NULL default '[]'
sentimenttextCHECK IN ('positive','neutral','negative')
key_topicstext[]NOT NULL default '{}'
entitiesjsonbNOT NULL default '[]'
created_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their call analyses" ON call_analyses
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_call_analyses_session on (call_session_id)
  • idx_call_analyses_owner on (owner_id, created_at DESC)

Foreign Keys: transcript_id -> call_transcripts(id) ON DELETE SET NULL

Services: TranscriptionService, ToolRegistry (query by call_session_id)


ivr_flows

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
phone_line_iduuidFK phone_lines(id) ON DELETE SET NULL
nametextNOT NULL
flow_definitionjsonbNOT NULL default '{}'
is_activebooleanNOT NULL default false
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their ivr flows" ON ivr_flows
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_ivr_flows_owner on (owner_id)
  • idx_ivr_flows_line on (phone_line_id, is_active)

Foreign Keys: phone_line_id -> phone_lines(id) ON DELETE SET NULL

Triggers: set_ivr_flows_updated_at BEFORE UPDATE -> trigger_set_updated_at()

Services: PhoneLineService


Migration 00044 -- Email Client

email_folders

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
nametextNOT NULL
ms_graph_idtext
parent_folder_iduuidFK email_folders(id) ON DELETE SET NULL
unread_countintegerNOT NULL default 0
total_countintegerNOT NULL default 0
folder_typetextNOT NULL default 'custom', CHECK IN ('inbox','sent','drafts','trash','archive','junk','custom')
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their email folders" ON email_folders
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_email_folders_owner on (owner_id)
  • idx_email_folders_owner_type on (owner_id, folder_type)
  • idx_email_folders_ms_graph_id on (owner_id, ms_graph_id)
  • idx_email_folders_parent on (parent_folder_id)

Foreign Keys: parent_folder_id -> email_folders(id) ON DELETE SET NULL

Triggers: set_email_folders_updated_at BEFORE UPDATE -> trigger_set_updated_at()

Services: EmailService


email_threads

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
ms_graph_conversation_idtext
subjecttextNOT NULL default '(No subject)'
last_message_attimestamptzNOT NULL default now()
folder_iduuidFK email_folders(id) ON DELETE SET NULL
participantsjsonbNOT NULL default '[]'
snippettext
unreadbooleanNOT NULL default true
starredbooleanNOT NULL default false
message_countintegerNOT NULL default 0
has_attachmentsbooleanNOT NULL default false
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their email threads" ON email_threads
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_email_threads_owner_folder_last on (owner_id, folder_id, last_message_at DESC)
  • idx_email_threads_owner_unread on (owner_id, unread, last_message_at DESC)
  • idx_email_threads_owner_starred on (owner_id, starred, last_message_at DESC)
  • idx_email_threads_ms_graph_conv on (owner_id, ms_graph_conversation_id)

Foreign Keys: folder_id -> email_folders(id) ON DELETE SET NULL

Triggers: set_email_threads_updated_at BEFORE UPDATE -> trigger_set_updated_at()

Services: EmailService (CRUD, mark read, star)


email_signatures

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
nametextNOT NULL
body_htmltextNOT NULL default ''
is_defaultbooleanNOT NULL default false
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their email signatures" ON email_signatures
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: idx_email_signatures_owner on (owner_id)

Triggers: set_email_signatures_updated_at BEFORE UPDATE -> trigger_set_updated_at()

Services: EmailService (CRUD, delete, default toggle)


Migration 00045 -- Meetings

meetings

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
titletextNOT NULL
room_nametextNOT NULL UNIQUE
scheduled_starttimestamptz
scheduled_endtimestamptz
statustextNOT NULL default 'scheduled', CHECK IN ('scheduled','active','ended')
settingsjsonbNOT NULL default '{}'
calendar_event_iduuidFK events(id) ON DELETE SET NULL
invite_linktext
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their meetings" ON meetings
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_meetings_owner_status on (owner_id, status)
  • idx_meetings_owner_scheduled on (owner_id, scheduled_start DESC)
  • idx_meetings_room_name on (room_name)

Foreign Keys: calendar_event_id -> events(id) ON DELETE SET NULL

Triggers: set_meetings_updated_at BEFORE UPDATE -> trigger_set_updated_at()

Services: MeetingService (full lifecycle -- create, start, join, end, update)


meeting_participants

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
meeting_iduuidNOT NULL, FK meetings(id) ON DELETE CASCADE
contact_iduuidFK persons(id) ON DELETE SET NULL
emailtext
roletextNOT NULL default 'participant', CHECK IN ('host','participant')
statustextNOT NULL default 'invited', CHECK IN ('invited','joined','left')
joined_attimestamptz
left_attimestamptz
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "meeting participants visible to meeting owner" ON meeting_participants
  USING (EXISTS (SELECT 1 FROM meetings WHERE meetings.id = meeting_participants.meeting_id AND meetings.owner_id = auth.uid()));

Indexes:

  • idx_meeting_participants_meeting on (meeting_id)
  • idx_meeting_participants_contact on (contact_id)

Foreign Keys: meeting_id -> meetings(id) ON DELETE CASCADE, contact_id -> persons(id) ON DELETE SET NULL

Triggers: set_meeting_participants_updated_at BEFORE UPDATE -> trigger_set_updated_at()

Services: MeetingService (insert/update)


meeting_recordings

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
meeting_iduuidNOT NULL, FK meetings(id) ON DELETE CASCADE
recording_sidtext
urltext
duration_secondsinteger
composition_statustextNOT NULL default 'enqueued', CHECK IN ('enqueued','processing','completed','failed')
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "meeting recordings visible to meeting owner" ON meeting_recordings
  USING (EXISTS (SELECT 1 FROM meetings WHERE meetings.id = meeting_recordings.meeting_id AND meetings.owner_id = auth.uid()));

Indexes: idx_meeting_recordings_meeting on (meeting_id)

Foreign Keys: meeting_id -> meetings(id) ON DELETE CASCADE

Triggers: set_meeting_recordings_updated_at BEFORE UPDATE -> trigger_set_updated_at()

Services: MeetingService (update composition status)


meeting_analyses

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
meeting_iduuidNOT NULL, FK meetings(id) ON DELETE CASCADE
transcript_iduuid
summarytext
action_itemsjsonbNOT NULL default '[]'
key_decisionsjsonbNOT NULL default '[]'
sentimenttextCHECK IN ('positive','neutral','negative')
key_topicstext[]NOT NULL default '{}'
entitiesjsonbNOT NULL default '{}'
created_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "meeting analyses visible to meeting owner" ON meeting_analyses
  USING (EXISTS (SELECT 1 FROM meetings WHERE meetings.id = meeting_analyses.meeting_id AND meetings.owner_id = auth.uid()));

Indexes: idx_meeting_analyses_meeting on (meeting_id)

Foreign Keys: meeting_id -> meetings(id) ON DELETE CASCADE

Services: MeetingService


Migration 00046 -- Contact Timeline

contact_notes

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
contact_iduuidNOT NULL, FK persons(id) ON DELETE CASCADE
bodytextNOT NULL
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their contact notes" ON contact_notes
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes: idx_contact_notes_owner_contact on (owner_id, contact_id, created_at DESC)

Foreign Keys: contact_id -> persons(id) ON DELETE CASCADE

Triggers: set_contact_notes_updated_at BEFORE UPDATE -> trigger_set_updated_at()

Services: ContactTimelineService (CRUD, delete)


contact_merges

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
primary_iduuidNOT NULL, FK persons(id) ON DELETE CASCADE
merged_iduuidNOT NULL, FK persons(id) ON DELETE CASCADE
merged_attimestamptzNOT NULL default now()
undone_attimestamptz

Unique: (primary_id, merged_id) (named unique_merge)

RLS: Enabled.

CREATE POLICY "users own their contact merges" ON contact_merges
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_contact_merges_owner on (owner_id)
  • idx_contact_merges_primary on (primary_id)
  • idx_contact_merges_merged on (merged_id)

Foreign Keys: primary_id -> persons(id) ON DELETE CASCADE, merged_id -> persons(id) ON DELETE CASCADE

Services: ContactTimelineService (merge/undo merge)


Migration 00047 -- Device Push Tokens

device_push_tokens

ColumnTypeConstraints
iduuidPK, default gen_random_uuid()
owner_iduuidNOT NULL, FK auth.users(id) ON DELETE CASCADE
device_idtextNOT NULL
fcm_tokentextNOT NULL
platformtextNOT NULL default 'android', CHECK IN ('android','ios','web')
device_nametext
is_activebooleanNOT NULL default true
created_attimestamptzNOT NULL default now()
updated_attimestamptzNOT NULL default now()

RLS: Enabled.

CREATE POLICY "users own their push tokens" ON device_push_tokens
  USING (auth.uid() = owner_id) WITH CHECK (auth.uid() = owner_id);

Indexes:

  • idx_push_tokens_owner_device UNIQUE on (owner_id, device_id)
  • idx_push_tokens_owner_active on (owner_id, is_active)
  • idx_push_tokens_fcm on (fcm_token)

Services: PushNotificationService (register/update)


Entity Relationship Map

auth.users (Supabase Auth)
  |
  +-- persons --------+-- messages (sender_person_id)
  |                    +-- events (organizer_id)
  |                    +-- tasks (assignee_id)
  |                    +-- documents (created_by)
  |                    +-- contact_notes (contact_id)
  |                    +-- contact_merges (primary_id, merged_id)
  |                    +-- inbox_items (contact_id)
  |                    +-- meeting_participants (contact_id)
  |
  +-- organizations ---+-- org_memberships (org_id)
  |                    +-- org_invites (org_id)
  |                    +-- usage_records (org_id)
  |                    +-- billing_events (org_id)
  |                    +-- stripe_customers (org_id)
  |                    +-- checkout_sessions (org_id)
  |
  +-- channels --------+-- conversations (channel_id)
  |
  +-- conversations ---+-- messages (conversation_id)
  |                    +-- inbox_items (conversation_id)
  |
  +-- messages --------+-- attachments (message_id)
  |
  +-- email_folders ---+-- email_threads (folder_id)
  |   (self-ref)       +-- messages (folder_id)
  |
  +-- email_threads ---+-- messages (email_thread_id)
  |
  +-- devices ---------+-- location_history (device_id)
  |
  +-- locations -------+-- inventory_items (location_id)
  |
  +-- events ----------+-- tasks (related_event)
  |                    +-- meetings (calendar_event_id)
  |
  +-- workflow_definitions -- workflow_runs (workflow_id)
  |
  +-- daos ------------+-- dao_members (dao_id)
  |                    +-- proposals (dao_id)
  |
  +-- proposals -------+-- votes (proposal_id)
  |
  +-- declarations ----+-- exchanges (offer_decl_id, need_decl_id)
  |
  +-- listings --------+-- marketplace_transactions (listing_id)
  |
  +-- outbound_webhooks -- webhook_delivery_log (webhook_id)
  |
  +-- collaboration_sessions -- collaboration_cursors (session_id)
  |
  +-- audio_sessions --+-- transcripts (session_id)
  |                    +-- voice_commands (session_id)
  |                    +-- extracted_intelligence (session_id)
  |                    +-- transcript_chunks (session_id)
  |                    +-- passive_intents (session_id)
  |
  +-- transcripts -----+-- extracted_intelligence (transcript_id)
  |
  +-- phone_lines -----+-- voicemails (phone_line_id)
  |                    +-- ivr_flows (phone_line_id)
  |
  +-- call_transcripts +-- call_analyses (transcript_id)
  |
  +-- meetings --------+-- meeting_participants (meeting_id)
  |                    +-- meeting_recordings (meeting_id)
  |                    +-- meeting_analyses (meeting_id)
  |
  +-- wiki_pages ------+-- wiki_links (from_page_id, to_page_id)
  |
  +-- inventory_items -+-- inventory_spaces (property_item_id)
  |   (self-ref)       +-- inventory_maintenance (item_id)
  |                    +-- inventory_events (item_id)
  |
  +-- inventory_spaces  (self-ref: parent_space_id)
  |
  +-- schedules -------+-- schedule_runs (schedule_id)
  |
  +-- plugin_registry -+-- user_plugins (plugin_id)
  |                    +-- plugin_ratings (plugin_id)
  |
  +-- oauth_apps ------+-- oauth_auth_codes (app_id)
                       +-- oauth_tokens (app_id)

Service-to-Table Map

ServiceTables ReadTables Written
DataServiceAll tables (generic CRUD)All tables (generic CRUD)
PolicyServiceaudit_logaudit_log
AuditServiceaudit_log, consent_records, retention_policies, compliance_reports, audit_alert_rulescompliance_reports, audit_alert_rules (delete)
RulesServicerules, rule_templates, persons, location_historyrule_execution_log, tasks, persons (tag updates)
ETLService--persons, documents, tasks, events, messages
AgentServiceagent_conversationsagent_conversations
AgentMemoryServiceagent_memory, agent_tool_callsagent_memory (upsert/delete), agent_tool_calls
WorkflowServiceworkflow_definitions, workflow_runsworkflow_runs
IntentionsServiceintentionsintentions
SchedulerServiceschedules, schedule_runsschedules, schedule_runs
ScheduledJobServiceuser_presence, recommendationsuser_presence, recommendations (delete)
DIDServicedidsdids
VCServiceverifiable_credentialsverifiable_credentials
DIDCommServicedidcomm_messagesdidcomm_messages
ActivityPubServicefederated_actors, follows, activitiesfederated_actors, follows, activities
MarketplaceServicelistingslistings
FederatedMarketplaceServicehub_subscriptions, federated_listing_cachehub_subscriptions, federated_listing_cache
ResourceCoordinationServicedeclarationsdeclarations
DAOServicedaos, dao_membersdaos, dao_members (delete)
VotingServicevotes, proposalsvotes, proposals (count updates)
TimeBankServicetime_credits, time_credit_transactionstime_credits, time_credit_transactions
ReputationServicereputation_scores, trust_relationshipsreputation_scores, trust_relationships (delete)
WalletServicewallet_connectionswallet_connections (delete)
TwilioCallingServicecall_sessionscall_sessions
InboxServiceinbox_itemsinbox_items
ContactTimelineServicecontact_notes, contact_merges, persons, inbox_itemscontact_notes (delete), contact_merges, persons, inbox_items
EmailServiceemail_threads, email_folders, email_signatures, messagesemail_threads, messages, email_signatures (delete)
MeetingServicemeetings, meeting_participants, meeting_recordingsmeetings, meeting_participants, meeting_recordings
PhoneLineServicephone_lines, voicemails, ivr_flowsphone_lines, voicemails, ivr_flows
AudioETLServiceaudio_sessions, transcriptstasks, extracted_intelligence
WikiServicewiki_pages, wiki_linkswiki_pages
InventoryServiceinventory_items, inventory_spaces, inventory_maintenance, inventory_eventsinventory_items, inventory_events, inventory_maintenance
ToolsServicetool_jobs, fontstool_jobs, fonts (delete)
PushNotificationServicedevice_push_tokensdevice_push_tokens
PresenceServiceuser_presence, presence_snapshotsuser_presence, presence_snapshots
ActivityFeedServiceactivity_feedactivity_feed
EmbeddingPipelineServiceembeddingsembeddings
SearchServiceembeddings--
SavedSearchServicesaved_searchessaved_searches (delete/update)
RecommendationEnginerecommendationsrecommendations (delete)
NotificationServicenotification_subscriptionsnotification_subscriptions (delete)
OutboundWebhookServiceoutbound_webhooks, webhook_delivery_logoutbound_webhooks (delete), webhook_delivery_log
EntityMergeServicepersons, merge_candidates, entity_lineage, conflict_resolution_rulespersons, merge_candidates
PluginRegistryServiceplugin_registry, user_plugins, plugin_ratingsplugin_registry, user_plugins (delete)
CredentialWalletServiceuser_credentialsuser_credentials
DeviceCommandServicedevice_commandsdevice_commands
LLMRoutingServicellm_routing_rules, llm_usagellm_usage
BillingServicestripe_customers, checkout_sessions, billing_events, usage_recordsAll billing tables
OAuthServiceoauth_apps, oauth_auth_codes, oauth_tokensAll OAuth tables
ErrorTrackingServicetracked_errorstracked_errors
ToolRegistry (AI)rules, call_analyses--