Skip to main content

Database schema

Status: Generated from the migrations in src/platform/dbmigrate/migrations; regenerate with make docs-generate.

What the migrations build on an empty database. Who writes each table, and how long rows are kept, is in docs/architecture/current/03-data-ownership.md.

Extensions: pg_trgm, vector

Schemas (ADR 0004): identity, runs, insights, billing, observatory and notify hold the tables of the service that writes them; public holds schema_migrations, the platform_* tables of the ports, and a view with the old name of every moved table (see the end).

public.platform_cache​

ColumnTypeNullDefault
keytextno
valuebyteano
expires_attimestamp with time zoneno

Indexes:

  • idx_platform_cache_expires: btree (expires_at)
  • platform_cache_pkey: unique, btree (key)

public.platform_jobs​

ColumnTypeNullDefault
idbigintnonextval('platform_jobs_id_seq'::regclass)
kindtextno
keytextyes
payloadbyteano'\x'::bytea
statetextno'waiting'::text
attemptsintegerno0
max_attemptsintegerno
run_attimestamp with time zonenonow()
lease_untiltimestamp with time zoneyes
tokentextyes
last_errortextyes
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()

Indexes:

  • idx_platform_jobs_due: btree (kind, run_at, id) WHERE (state = 'waiting'::text)
  • idx_platform_jobs_key: unique, btree (kind, key) WHERE ((key IS NOT NULL) AND (state <> 'dead'::text))
  • idx_platform_jobs_leases: btree (kind, lease_until) WHERE (state = 'running'::text)
  • platform_jobs_pkey: unique, btree (id)

public.platform_locks​

ColumnTypeNullDefault
nametextno
holdertextno
expires_attimestamp with time zoneno

Indexes:

  • platform_locks_pkey: unique, btree (name)

public.platform_rate_limits​

ColumnTypeNullDefault
keytextno
countintegerno
expires_attimestamp with time zoneno

Indexes:

  • idx_platform_rate_limits_expires: btree (expires_at)
  • platform_rate_limits_pkey: unique, btree (key)

public.schema_migrations​

ColumnTypeNullDefault
versionbigintno
namecharacter varying(255)no
dirtybooleannofalse
applied_attimestamp with time zonenonow()

Indexes:

  • schema_migrations_pkey: unique, btree (version)

identity.accounts​

ColumnTypeNullDefault
idbigintnonextval('identity.accounts_id_seq'::regclass)
github_user_idbigintyes
github_logintextyes
display_nametextyes
emailtextyes
plantextno'none'::text
is_ownerbooleannofalse
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()
disabled_attimestamp with time zoneyes
research_opt_in_attimestamp with time zoneyes
plan_versionbigintno0

Indexes:

  • accounts_github_user_id_key: unique, btree (github_user_id)
  • accounts_pkey: unique, btree (id)
  • idx_accounts_single_owner: unique, btree (is_owner) WHERE is_owner
ColumnTypeNullDefault
idbigintnonextval('identity.agent_link_requests_id_seq'::regclass)
device_code_hashbyteano
user_codetextno
agent_nametextno
hostnametextyes
versiontextyes
statustextno'pending'::text
account_idbigintyes
created_attimestamp with time zonenonow()
expires_attimestamp with time zoneno
approved_attimestamp with time zoneyes
last_polled_attimestamp with time zoneyes

Foreign keys:

  • agent_link_requests_account_id_fkey: FOREIGN KEY (account_id) REFERENCES identity.accounts(id)

Indexes:

  • agent_link_requests_device_code_hash_key: unique, btree (device_code_hash)
  • agent_link_requests_pkey: unique, btree (id)
  • idx_agent_link_user_code_pending: unique, btree (user_code) WHERE (status = 'pending'::text)

identity.agents​

ColumnTypeNullDefault
idbigintnonextval('identity.agents_id_seq'::regclass)
account_idbigintno
nametextno
hostnametextyes
versiontextyes
created_attimestamp with time zonenonow()
last_seen_attimestamp with time zoneyes
revoked_attimestamp with time zoneyes

Foreign keys:

  • agents_account_id_fkey: FOREIGN KEY (account_id) REFERENCES identity.accounts(id)

Indexes:

  • agents_pkey: unique, btree (id)
  • idx_agents_account: btree (account_id)

identity.api_tokens​

ColumnTypeNullDefault
idbigintnonextval('identity.api_tokens_id_seq'::regclass)
account_idbigintno
kindtextno
agent_idbigintyes
nametextno
token_hashbyteano
displaytextno
scopestext[]no
created_attimestamp with time zonenonow()
last_used_attimestamp with time zoneyes
expires_attimestamp with time zoneyes
revoked_attimestamp with time zoneyes

Foreign keys:

  • api_tokens_account_id_fkey: FOREIGN KEY (account_id) REFERENCES identity.accounts(id)
  • api_tokens_agent_id_fkey: FOREIGN KEY (agent_id) REFERENCES identity.agents(id)

Indexes:

  • api_tokens_pkey: unique, btree (id)
  • api_tokens_token_hash_key: unique, btree (token_hash)
  • idx_api_tokens_account: btree (account_id)

identity.audit_events​

ColumnTypeNullDefault
idbigintnonextval('identity.audit_events_id_seq'::regclass)
account_idbigintyes
actortextno
actiontextno
targettextyes
detailjsonbno'{}'::jsonb
created_attimestamp with time zonenonow()

Foreign keys:

  • audit_events_account_id_fkey: FOREIGN KEY (account_id) REFERENCES identity.accounts(id)

Indexes:

  • audit_events_pkey: unique, btree (id)
  • idx_audit_events_account: btree (account_id, created_at DESC)

identity.outbox​

ColumnTypeNullDefault
idbigintnonextval('identity.outbox_id_seq'::regclass)
event_iduuidnogen_random_uuid()
typetextno
versionintegerno
account_idbigintno
dedup_keytextno
occurred_attimestamp with time zonenonow()
datajsonbno'{}'::jsonb
published_attimestamp with time zoneyes

Indexes:

  • idx_outbox_account: btree (account_id)
  • idx_outbox_unpublished: btree (id) WHERE (published_at IS NULL)
  • outbox_dedup_key_key: unique, btree (dedup_key)
  • outbox_event_id_key: unique, btree (event_id)
  • outbox_pkey: unique, btree (id)

identity.revocations​

ColumnTypeNullDefault
idbigintnonextval('identity.revocations_id_seq'::regclass)
token_idbigintyes
agent_idbigintyes
account_idbigintyes
attimestamp with time zonenoclock_timestamp()

Indexes:

  • idx_revocations_at: btree (at)
  • revocations_pkey: unique, btree (id)

identity.waitlist_signups​

ColumnTypeNullDefault
idbigintnonextval('identity.waitlist_signups_id_seq'::regclass)
emailtextno
sourcetextno'landing'::text
created_attimestamp with time zonenonow()

Indexes:

  • idx_waitlist_signups_email: unique, btree (lower(email))
  • waitlist_signups_pkey: unique, btree (id)

runs.account_versions​

ColumnTypeNullDefault
account_idbigintno
runs_versionbigintno0
requests_versionbigintno0
updated_attimestamp with time zonenonow()

Indexes:

  • account_versions_pkey: unique, btree (account_id)

runs.analytics_snapshots​

ColumnTypeNullDefault
run_idintegerno
captured_attimestamp with time zoneyesnow()
head_committextyes''::text
head_commit_messagetextyes''::text
head_commit_attimestamp with time zoneyes
total_commitsintegeryes0
branch_countintegeryes0
tag_countintegeryes0
tracked_filesintegeryes0
total_blob_size_bytesbigintyes0
avg_blob_size_bytesbigintyes0
largest_blob_pathtextyes''::text
largest_blob_size_bytesbigintyes0
archive_countintegeryes0
total_archive_size_bytesbigintyes0
avg_archive_size_bytesbigintyes0
largest_archive_pathtextyes''::text
largest_archive_size_bytesbigintyes0
account_idbigintno

Foreign keys:

  • analytics_snapshots_run_id_fkey: FOREIGN KEY (run_id) REFERENCES runs.backup_runs(id) ON DELETE CASCADE

Indexes:

  • analytics_snapshots_pkey: unique, btree (run_id)
  • idx_analytics_snapshots_account: btree (account_id, captured_at)
  • idx_analytics_snapshots_time: btree (captured_at)

runs.backup_fix_commits​

ColumnTypeNullDefault
idintegernonextval('runs.backup_fix_commits_id_seq'::regclass)
fix_idintegerno
commit_hashtextno
created_attimestamp with time zoneyesnow()

Foreign keys:

  • backup_fix_commits_fix_id_fkey: FOREIGN KEY (fix_id) REFERENCES runs.backup_fixes(id) ON DELETE CASCADE

Indexes:

  • backup_fix_commits_fix_id_key: unique, btree (fix_id)
  • backup_fix_commits_pkey: unique, btree (id)
  • idx_backup_fix_commits_fix: btree (fix_id)
  • idx_backup_fix_commits_hash: btree (commit_hash)

runs.backup_fixes​

ColumnTypeNullDefault
idintegernonextval('runs.backup_fixes_id_seq'::regclass)
titletextno
descriptiontextno''::text
authortextyes''::text
created_attimestamp with time zoneyesnow()
updated_attimestamp with time zoneyesnow()
account_idbigintno
idempotency_keytextyes
request_sha256byteayes
recorded_bytextyes

Indexes:

  • backup_fixes_pkey: unique, btree (id)
  • idx_backup_fixes_account: btree (account_id, created_at)
  • idx_backup_fixes_idempotency: unique, btree (account_id, idempotency_key) WHERE (idempotency_key IS NOT NULL)

runs.backup_result_errors​

ColumnTypeNullDefault
idintegernonextval('runs.backup_result_errors_id_seq'::regclass)
result_idintegerno
error_messagetextno
created_attimestamp with time zoneyesnow()

Foreign keys:

  • backup_result_errors_result_id_fkey: FOREIGN KEY (result_id) REFERENCES runs.backup_results(id) ON DELETE CASCADE

Indexes:

  • backup_result_errors_pkey: unique, btree (id)
  • backup_result_errors_result_id_key: unique, btree (result_id)
  • idx_backup_result_errors_result: btree (result_id)

runs.backup_results​

ColumnTypeNullDefault
idintegernonextval('runs.backup_results_id_seq'::regclass)
run_idintegeryes
repo_full_nametextno
statustextno'pending'::text
commit_hashtextyes''::text
archive_size_bytesbigintyes0
duration_msbigintyes0
created_attimestamp with time zoneyesnow()
account_idbigintno
reason_codetextyes
stat_outcometextyes
clone_msbigintyes
pack_msbigintyes
upload_msbigintyes
cloned_bytesbigintyes

Foreign keys:

  • backup_results_run_id_fkey: FOREIGN KEY (run_id) REFERENCES runs.backup_runs(id) ON DELETE CASCADE

Indexes:

  • backup_results_pkey: unique, btree (id)
  • idx_backup_results_account: btree (account_id, created_at)
  • idx_backup_results_account_repo_latest: btree (account_id, repo_full_name, created_at DESC NULLS LAST, id DESC)
  • idx_backup_results_commit: btree (commit_hash) WHERE (commit_hash IS NOT NULL)
  • idx_backup_results_repo_latest: btree (repo_full_name, created_at DESC NULLS LAST, id DESC)
  • idx_backup_results_run: btree (run_id)
  • idx_backup_results_size: btree (archive_size_bytes DESC NULLS LAST, created_at DESC, id DESC)
  • idx_backup_results_status_failed: btree (run_id, status) WHERE (status = 'failed'::text)

runs.backup_run_errors​

ColumnTypeNullDefault
idintegernonextval('runs.backup_run_errors_id_seq'::regclass)
run_idintegerno
error_messagetextno
created_attimestamp with time zoneyesnow()

Foreign keys:

  • backup_run_errors_run_id_fkey: FOREIGN KEY (run_id) REFERENCES runs.backup_runs(id) ON DELETE CASCADE

Indexes:

  • backup_run_errors_pkey: unique, btree (id)
  • backup_run_errors_run_id_key: unique, btree (run_id)
  • idx_backup_run_errors_run: btree (run_id)

runs.backup_run_fixes​

ColumnTypeNullDefault
run_idintegerno
fix_idintegerno

Foreign keys:

  • backup_run_fixes_fix_id_fkey: FOREIGN KEY (fix_id) REFERENCES runs.backup_fixes(id) ON DELETE CASCADE
  • backup_run_fixes_run_id_fkey: FOREIGN KEY (run_id) REFERENCES runs.backup_runs(id) ON DELETE CASCADE

Indexes:

  • backup_run_fixes_pkey: unique, btree (run_id, fix_id)
  • idx_backup_run_fixes_fix: btree (fix_id)
  • idx_backup_run_fixes_run: btree (run_id)

runs.backup_run_requests​

ColumnTypeNullDefault
idbigintnonextval('runs.backup_run_requests_id_seq'::regclass)
target_repotextyes
requested_bytextno
reasontextyes
statustextno'pending'::text
run_idbigintyes
created_attimestamp with time zonenonow()
started_attimestamp with time zoneyes
finished_attimestamp with time zoneyes
account_idbigintno

Indexes:

  • backup_run_requests_pkey: unique, btree (id)
  • idx_backup_run_requests_account: btree (account_id, created_at)
  • idx_backup_run_requests_one_pending: unique, btree (account_id, lower(COALESCE(target_repo, ''::text))) WHERE (status = 'pending'::text)
  • idx_backup_run_requests_pending: btree (created_at) WHERE (status = 'pending'::text)

runs.backup_runs​

ColumnTypeNullDefault
idintegernonextval('runs.backup_runs_id_seq'::regclass)
statustextno'running'::text
started_attimestamp with time zoneyesnow()
completed_attimestamp with time zoneyes
total_reposintegeryes0
successfulintegeryes0
failedintegeryes0
skippedintegeryes0
duration_msbigintyes0
full_runbooleannotrue
account_idbigintno
telemetryjsonbyes
agent_versiontextyes
agent_ostextyes
sink_typetextyes

Indexes:

  • backup_runs_pkey: unique, btree (id)
  • idx_backup_runs_account: btree (account_id, started_at)
  • idx_backup_runs_account_running: btree (account_id) WHERE (status = 'running'::text)
  • idx_backup_runs_status_failed: btree (status) WHERE (status = 'failed'::text)

runs.execution_logs​

ColumnTypeNullDefault
idbigintnonextval('runs.execution_logs_id_seq'::regclass)
run_idintegeryes
leveltextno'info'::text
messagetextno
repositorytextyes''::text
created_attimestamp with time zoneyesnow()
account_idbigintno

Foreign keys:

  • execution_logs_run_id_fkey: FOREIGN KEY (run_id) REFERENCES runs.backup_runs(id) ON DELETE CASCADE

Indexes:

  • execution_logs_pkey: unique, btree (id)
  • idx_execution_logs_account: btree (account_id, created_at, id)
  • idx_execution_logs_account_level: btree (account_id, lower(level), created_at, id) WHERE (lower(level) <> 'info'::text)
  • idx_execution_logs_run: btree (run_id)
  • idx_execution_logs_time: btree (created_at)

runs.outbox​

ColumnTypeNullDefault
idbigintnonextval('runs.outbox_id_seq'::regclass)
event_iduuidnogen_random_uuid()
typetextno
versionintegerno
account_idbigintno
dedup_keytextno
occurred_attimestamp with time zonenonow()
datajsonbno'{}'::jsonb
published_attimestamp with time zoneyes

Indexes:

  • idx_outbox_account: btree (account_id)
  • idx_outbox_unpublished: btree (id) WHERE (published_at IS NULL)
  • outbox_dedup_key_key: unique, btree (dedup_key)
  • outbox_event_id_key: unique, btree (event_id)
  • outbox_pkey: unique, btree (id)
ColumnTypeNullDefault
account_idbigintno
opted_in_attimestamp with time zoneyes
updated_attimestamp with time zonenonow()

Indexes:

  • research_consent_pkey: unique, btree (account_id)

runs.research_samples​

ColumnTypeNullDefault
idbigintnonextval('runs.research_samples_id_seq'::regclass)
account_idbigintno
run_idintegeryes
repo_idtextno
reason_codetextno
statustextyes
stat_outcometextyes
prior_pushed_attimestamp with time zoneyes
pushed_attimestamp with time zoneyes
size_buckettextno
cloned_bytesbigintyes
archive_bytesbigintyes
clone_msbigintyes
pack_msbigintyes
upload_msbigintyes
shadow_headtextyes
shadow_refstextyes
shadow_errortextyes
agent_versiontextyes
agent_ostextyes
sink_typetextyes
created_attimestamp with time zonenonow()

Foreign keys:

  • research_samples_run_id_fkey: FOREIGN KEY (run_id) REFERENCES runs.backup_runs(id) ON DELETE SET NULL

Indexes:

  • idx_research_samples_account: btree (account_id, created_at)
  • idx_research_samples_created: btree (created_at)
  • idx_research_samples_repo: btree (repo_id, created_at)
  • idx_research_samples_run_repo: unique, btree (run_id, repo_id)
  • research_samples_pkey: unique, btree (id)

runs.worker_repo_state​

ColumnTypeNullDefault
repo_full_nametextno
display_nametextno
privatebooleannofalse
pushed_attimestamp with time zoneyes
archive_formattextno
archive_keytextyes
archive_sha256textyes
archive_size_bytesbigintyes
statustextno
last_errortextyes
last_attempt_attimestamp with time zoneyes
last_backed_up_attimestamp with time zoneyes
missing_sincetimestamp with time zoneyes
updated_attimestamp with time zonenonow()
account_idbigintno

Indexes:

  • worker_repo_state_pkey: unique, btree (account_id, repo_full_name)

runs.worker_run_lease​

ColumnTypeNullDefault
lease_nametextno
holdertextno
acquired_attimestamp with time zoneno
heartbeat_attimestamp with time zoneno
expires_attimestamp with time zoneno
account_idbigintno

Indexes:

  • worker_run_lease_pkey: unique, btree (account_id, lease_name)

insights.account_rollups​

ColumnTypeNullDefault
account_idbigintno
source_versionbigintno
runsbigintno
successfulbigintno
failedbigintno
skippedbigintno
total_reposbigintno
duration_ms_sumbigintno
duration_ms_countbigintno
distinct_reposbigintno
total_size_bytesbigintno
largest_archive_bytesbigintno
largest_repositorytextno
computed_attimestamp with time zonenonow()

Indexes:

  • account_rollups_pkey: unique, btree (account_id)

billing.cohorts​

ColumnTypeNullDefault
idtextno
plan_idtextno
nametextno
positionintegerno
seatsintegeryes

Foreign keys:

  • cohorts_plan_id_fkey: FOREIGN KEY (plan_id) REFERENCES billing.plans(id)

Indexes:

  • cohorts_pkey: unique, btree (id)
  • cohorts_plan_id_position_key: unique, btree (plan_id, "position")

billing.customers​

ColumnTypeNullDefault
account_idbigintno
nametextno
emailtextno
countrytextno
statetextyes
gstintextyes
addresstextno''::text
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()

Indexes:

  • customers_pkey: unique, btree (account_id)

billing.document_sequences​

ColumnTypeNullDefault
seriestextno
financial_yeartextno
lastintegerno0

Indexes:

  • document_sequences_pkey: unique, btree (series, financial_year)

billing.entitlement_versions​

ColumnTypeNullDefault
account_idbigintno
versionbigintno0

Indexes:

  • entitlement_versions_pkey: unique, btree (account_id)

billing.invoices​

ColumnTypeNullDefault
idbigintnonextval('billing.invoices_id_seq'::regclass)
numbertextno
account_idbigintno
payment_idbigintno
issued_attimestamp with time zonenonow()
currencytextno
total_minorbigintno
taxable_minorbigintno
tax_minorbigintno
tax_rate_bpsintegerno
tax_kindtextno
sellerjsonbno
buyerjsonbno
linesjsonbno

Foreign keys:

  • invoices_payment_id_fkey: FOREIGN KEY (payment_id) REFERENCES billing.payments(id)

Indexes:

  • idx_invoices_account: btree (account_id, issued_at DESC)
  • invoices_number_key: unique, btree (number)
  • invoices_payment_id_key: unique, btree (payment_id)
  • invoices_pkey: unique, btree (id)

billing.outbox​

ColumnTypeNullDefault
idbigintnonextval('billing.outbox_id_seq'::regclass)
event_iduuidnogen_random_uuid()
typetextno
versionintegerno
account_idbigintno
dedup_keytextno
occurred_attimestamp with time zonenonow()
datajsonbno'{}'::jsonb
published_attimestamp with time zoneyes

Indexes:

  • idx_billing_outbox_account: btree (account_id)
  • idx_billing_outbox_unpublished: btree (id) WHERE (published_at IS NULL)
  • outbox_dedup_key_key: unique, btree (dedup_key)
  • outbox_event_id_key: unique, btree (event_id)
  • outbox_pkey: unique, btree (id)

billing.payments​

ColumnTypeNullDefault
idbigintnonextval('billing.payments_id_seq'::regclass)
account_idbigintno
subscription_idbigintno
providertextno
provider_reftextno
amount_minorbigintno
currencytextno
statustextno
methodtextno''::text
failure_reasontextno''::text
paid_attimestamp with time zoneyes
created_attimestamp with time zonenonow()

Foreign keys:

  • payments_subscription_id_fkey: FOREIGN KEY (subscription_id) REFERENCES billing.subscriptions(id)

Indexes:

  • idx_payments_account: btree (account_id, created_at DESC)
  • idx_payments_subscription: btree (subscription_id, created_at)
  • payments_pkey: unique, btree (id)
  • payments_provider_provider_ref_key: unique, btree (provider, provider_ref)

billing.plans​

ColumnTypeNullDefault
idtextno
nametextno
descriptiontextno''::text
entitlestextno
positionintegerno0
activebooleannotrue
created_attimestamp with time zonenonow()

Indexes:

  • plans_pkey: unique, btree (id)

billing.prices​

ColumnTypeNullDefault
idtextno
cohort_idtextno
currencytextno
amount_minorbigintno
modetextno
periodtextno'year'::text
tax_inclusivebooleannotrue
activebooleannotrue

Foreign keys:

  • prices_cohort_id_fkey: FOREIGN KEY (cohort_id) REFERENCES billing.cohorts(id)

Indexes:

  • prices_cohort_id_currency_key: unique, btree (cohort_id, currency)
  • prices_pkey: unique, btree (id)

billing.provider_refs​

ColumnTypeNullDefault
providertextno
kindtextno
local_idtextno
external_idtextno
created_attimestamp with time zonenonow()

Indexes:

  • provider_refs_pkey: unique, btree (provider, kind, local_id)

billing.refunds​

ColumnTypeNullDefault
idbigintnonextval('billing.refunds_id_seq'::regclass)
account_idbigintno
payment_idbigintno
providertextno
provider_reftextyes
amount_minorbigintno
fee_minorbigintno
statustextno'requested'::text
credit_note_numbertextyes
requested_attimestamp with time zonenonow()
processed_attimestamp with time zoneyes

Foreign keys:

  • refunds_payment_id_fkey: FOREIGN KEY (payment_id) REFERENCES billing.payments(id)

Indexes:

  • idx_refunds_one_per_payment: unique, btree (payment_id) WHERE (status <> 'failed'::text)
  • idx_refunds_payment: btree (payment_id)
  • refunds_credit_note_number_key: unique, btree (credit_note_number)
  • refunds_pkey: unique, btree (id)
  • refunds_provider_provider_ref_key: unique, btree (provider, provider_ref)

billing.subscriptions​

ColumnTypeNullDefault
idbigintnonextval('billing.subscriptions_id_seq'::regclass)
account_idbigintno
price_idtextno
providertextno
provider_reftextyes
modetextno
statustextno'pending'::text
checkout_urltextyes
checkout_expires_attimestamp with time zoneyes
current_period_starttimestamp with time zoneyes
current_period_endtimestamp with time zoneyes
activated_attimestamp with time zoneyes
ended_attimestamp with time zoneyes
renews_idbigintyes
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()

Foreign keys:

  • subscriptions_price_id_fkey: FOREIGN KEY (price_id) REFERENCES billing.prices(id)
  • subscriptions_renews_id_fkey: FOREIGN KEY (renews_id) REFERENCES billing.subscriptions(id)

Indexes:

  • idx_subscriptions_account: btree (account_id, created_at DESC)
  • idx_subscriptions_one_open_checkout: unique, btree (account_id) WHERE (status = 'pending'::text)
  • idx_subscriptions_open_checkouts: btree (checkout_expires_at) WHERE (status = 'pending'::text)
  • idx_subscriptions_period_end: btree (current_period_end) WHERE (status = ANY (ARRAY['active'::text, 'past_due'::text, 'cancelled'::text]))
  • idx_subscriptions_price: btree (price_id)
  • idx_subscriptions_renews: btree (renews_id)
  • subscriptions_pkey: unique, btree (id)
  • subscriptions_provider_provider_ref_key: unique, btree (provider, provider_ref)

billing.webhook_events​

ColumnTypeNullDefault
providertextno
event_idtextno
typetextno
received_attimestamp with time zonenonow()
processed_attimestamp with time zoneyes
payloadjsonbyes

Indexes:

  • idx_webhook_events_received: btree (received_at)
  • webhook_events_pkey: unique, btree (provider, event_id)

observatory.ai_chat_messages​

ColumnTypeNullDefault
iduuidno
session_iduuidyes
request_iduuidno
rolecharacter varyingno
contenttextno
created_attimestamp with time zonenonow()

Foreign keys:

  • ai_chat_messages_session_id_fkey: FOREIGN KEY (session_id) REFERENCES observatory.ai_chat_sessions(id)

Indexes:

  • ai_chat_messages_pkey: unique, btree (id)
  • idx_ai_chat_messages_request_id: btree (request_id)
  • idx_ai_chat_messages_session_id: btree (session_id)

observatory.ai_chat_sessions​

ColumnTypeNullDefault
iduuidno
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()
session_namecharacter varyingyes
account_idbigintno

Foreign keys:

  • ai_chat_sessions_account_id_fkey: FOREIGN KEY (account_id) REFERENCES identity.accounts(id)

Indexes:

  • ai_chat_sessions_pkey: unique, btree (id)
  • idx_ai_chat_sessions_account: btree (account_id, updated_at)

observatory.ai_openrouter_credentials​

ColumnTypeNullDefault
usernametextno
key_ciphertexttextno
key_hinttextno
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()
last_used_attimestamp with time zoneyes
invalid_attimestamp with time zoneyes
account_idbigintyes

Foreign keys:

  • ai_openrouter_credentials_account_id_fkey: FOREIGN KEY (account_id) REFERENCES identity.accounts(id)

Indexes:

  • ai_openrouter_credentials_account_id_key: unique, btree (account_id)
  • ai_openrouter_credentials_pkey: unique, btree (username)

observatory.ai_reports​

ColumnTypeNullDefault
iduuidno
report_typecharacter varyingno
subjectcharacter varyingno
recipientsjsonbno
content_htmltextyes
content_markdowntextyes
statuscharacter varyingno
pdf_pathcharacter varyingyes
error_messagetextyes
sent_attimestamp with time zoneyes
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()
account_idbigintno

Foreign keys:

  • ai_reports_account_id_fkey: FOREIGN KEY (account_id) REFERENCES identity.accounts(id)

Indexes:

  • ai_reports_pkey: unique, btree (id)
  • idx_ai_reports_account: btree (account_id, created_at)
  • idx_ai_reports_created_at: btree (created_at)

observatory.ai_session_metadata​

ColumnTypeNullDefault
iduuidno
session_iduuidno
metadatajsonbno
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()

Foreign keys:

  • ai_session_metadata_session_id_fkey: FOREIGN KEY (session_id) REFERENCES observatory.ai_chat_sessions(id) ON DELETE CASCADE

Indexes:

  • ai_session_metadata_pkey: unique, btree (id)
  • ai_session_metadata_session_id_key: unique, btree (session_id)
  • idx_ai_session_metadata_session: btree (session_id)

observatory.ai_tool_call_args​

ColumnTypeNullDefault
iduuidno
tool_call_iduuidno
argsjsonbno
created_attimestamp with time zonenonow()

Foreign keys:

  • ai_tool_call_args_tool_call_id_fkey: FOREIGN KEY (tool_call_id) REFERENCES observatory.ai_tool_calls(id) ON DELETE CASCADE

Indexes:

  • ai_tool_call_args_pkey: unique, btree (id)
  • ai_tool_call_args_tool_call_id_key: unique, btree (tool_call_id)
  • idx_ai_tool_call_args_tool: btree (tool_call_id)

observatory.ai_tool_call_errors​

ColumnTypeNullDefault
iduuidno
tool_call_iduuidno
errortextno
created_attimestamp with time zonenonow()

Foreign keys:

  • ai_tool_call_errors_tool_call_id_fkey: FOREIGN KEY (tool_call_id) REFERENCES observatory.ai_tool_calls(id) ON DELETE CASCADE

Indexes:

  • ai_tool_call_errors_pkey: unique, btree (id)
  • ai_tool_call_errors_tool_call_id_key: unique, btree (tool_call_id)
  • idx_ai_tool_call_errors_tool: btree (tool_call_id)

observatory.ai_tool_calls​

ColumnTypeNullDefault
iduuidno
request_iduuidno
namecharacter varyingno
resultjsonbyes
successbooleanno
duration_msdouble precisionyes
created_attimestamp with time zonenonow()

Indexes:

  • ai_tool_calls_pkey: unique, btree (id)
  • idx_ai_tool_calls_request_id: btree (request_id)
  • idx_ai_tool_calls_success_false: btree (name) WHERE (success = false)

observatory.ai_tool_confirmations​

ColumnTypeNullDefault
confirm_iduuidno
session_iduuidyes
request_iduuidyes
usernametextno
tool_nametextno
argsjsonbno'{}'::jsonb
statustextno'pending'::text
created_attimestamp with time zonenonow()
decided_attimestamp with time zoneyes
account_idbigintno

Foreign keys:

  • ai_tool_confirmations_account_id_fkey: FOREIGN KEY (account_id) REFERENCES identity.accounts(id)

Indexes:

  • ai_tool_confirmations_pkey: unique, btree (confirm_id)
  • idx_ai_tool_confirmations_account: btree (account_id, created_at)
  • idx_ai_tool_confirmations_pending: btree (created_at) WHERE (status = 'pending'::text)
  • idx_ai_tool_confirmations_session: btree (session_id)

observatory.embedding_chunk_metadata​

ColumnTypeNullDefault
idintegernonextval('observatory.embedding_chunk_metadata_id_seq'::regclass)
chunk_idintegerno
metadatajsonbno'{}'::jsonb
created_attimestamp with time zoneyesnow()

Foreign keys:

  • embedding_chunk_metadata_chunk_id_fkey: FOREIGN KEY (chunk_id) REFERENCES observatory.embedding_chunks(id) ON DELETE CASCADE

Indexes:

  • embedding_chunk_metadata_chunk_id_key: unique, btree (chunk_id)
  • embedding_chunk_metadata_pkey: unique, btree (id)
  • idx_embedding_chunk_metadata_chunk: btree (chunk_id)
  • idx_embedding_chunk_metadata_gin: gin (metadata)

observatory.embedding_chunks​

ColumnTypeNullDefault
idintegernonextval('observatory.embedding_chunks_id_seq'::regclass)
generation_idintegerno
source_typetextno
source_idtextno
chunk_indexintegerno0
contenttextno
content_hashtextno
embeddingvectoryes
content_tsvtsvectoryesto_tsvector('english'::regconfig, content)
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()
account_idbigintno

Foreign keys:

  • embedding_chunks_account_id_fkey: FOREIGN KEY (account_id) REFERENCES identity.accounts(id)
  • embedding_chunks_generation_id_fkey: FOREIGN KEY (generation_id) REFERENCES observatory.embedding_generations(id) ON DELETE CASCADE

Indexes:

  • embedding_chunks_pkey: unique, btree (id)
  • idx_embedding_chunks_account: btree (account_id, generation_id)
  • idx_embedding_chunks_fts: gin (content_tsv)
  • idx_embedding_chunks_gen_type: btree (generation_id, source_type)
  • idx_embedding_chunks_generation: btree (generation_id)
  • idx_embedding_chunks_hnsw_1024: hnsw (((embedding)::vector(1024)) vector_cosine_ops) WHERE (vector_dims(embedding) = 1024)
  • idx_embedding_chunks_source: btree (source_type, source_id)
  • idx_embedding_chunks_trgm: gin (content gin_trgm_ops)
  • idx_embedding_chunks_unique_source: unique, btree (generation_id, source_type, source_id, chunk_index)

observatory.embedding_generations​

ColumnTypeNullDefault
idintegernonextval('observatory.embedding_generations_id_seq'::regclass)
model_idtextno
dimensionsintegerno
statustextno'BUILDING'::text
created_attimestamp with time zonenonow()
activated_attimestamp with time zoneyes
completed_attimestamp with time zoneyes
retired_attimestamp with time zoneyes
total_itemsintegerno0
processed_itemsintegerno0
failed_itemsintegerno0
backfill_started_attimestamp with time zoneyes
backfill_completed_attimestamp with time zoneyes

Indexes:

  • embedding_generations_pkey: unique, btree (id)
  • idx_embedding_generations_single_active: unique, btree (status) WHERE (status = 'ACTIVE'::text)

observatory.embedding_indexing_checkpoints​

ColumnTypeNullDefault
source_typetextno
last_indexed_idbigintno0
updated_attimestamp with time zonenonow()

Indexes:

  • embedding_indexing_checkpoints_pkey: unique, btree (source_type)

observatory.embedding_job_errors​

ColumnTypeNullDefault
idintegernonextval('observatory.embedding_job_errors_id_seq'::regclass)
job_idbigintno
error_messagetextno
created_attimestamp with time zoneyesnow()

Foreign keys:

  • embedding_job_errors_job_id_fkey: FOREIGN KEY (job_id) REFERENCES observatory.embedding_jobs(id) ON DELETE CASCADE

Indexes:

  • embedding_job_errors_job_id_key: unique, btree (job_id)
  • embedding_job_errors_pkey: unique, btree (id)
  • idx_embedding_job_errors_job: btree (job_id)

observatory.embedding_jobs​

ColumnTypeNullDefault
idbigintnonextval('observatory.embedding_jobs_id_seq'::regclass)
generation_idintegerno
source_typetextno
source_idtextno
content_hashtextno''::text
statustextno'pending'::text
attempt_countintegerno0
max_attemptsintegerno3
claimed_attimestamp with time zoneyes
completed_attimestamp with time zoneyes
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()
account_idbigintyes
contenttextyes
metadatajsonbyes

Foreign keys:

  • embedding_jobs_generation_id_fkey: FOREIGN KEY (generation_id) REFERENCES observatory.embedding_generations(id) ON DELETE CASCADE

Indexes:

  • embedding_jobs_pkey: unique, btree (id)
  • idx_embedding_jobs_account: btree (account_id) WHERE (account_id IS NOT NULL)
  • idx_embedding_jobs_claimable: btree (generation_id, status, attempt_count) WHERE (status = ANY (ARRAY['pending'::text, 'failed'::text]))
  • idx_embedding_jobs_status: btree (generation_id, status)
  • idx_embedding_jobs_unique: unique, btree (generation_id, source_type, source_id)

observatory.investigation_errors​

ColumnTypeNullDefault
iduuidno
investigation_iduuidno
errortextno
created_attimestamp with time zonenonow()

Foreign keys:

  • investigation_errors_investigation_id_fkey: FOREIGN KEY (investigation_id) REFERENCES observatory.investigations(id) ON DELETE CASCADE

Indexes:

  • idx_investigation_errors_investigation: btree (investigation_id)
  • investigation_errors_investigation_id_key: unique, btree (investigation_id)
  • investigation_errors_pkey: unique, btree (id)

observatory.investigations​

ColumnTypeNullDefault
iduuidno
request_iduuidno
session_iduuidyes
questiontextno
answertextyes
tool_callsjsonbno
tool_resultsjsonbno
statuscharacter varyingno
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()
account_idbigintno

Foreign keys:

  • investigations_account_id_fkey: FOREIGN KEY (account_id) REFERENCES identity.accounts(id)
  • investigations_session_id_fkey: FOREIGN KEY (session_id) REFERENCES observatory.ai_chat_sessions(id)

Indexes:

  • idx_investigations_account: btree (account_id, created_at)
  • idx_investigations_created_at: btree (created_at)
  • idx_investigations_request_id: btree (request_id)
  • idx_investigations_session_id: btree (session_id)
  • idx_investigations_status_failed: btree (status) WHERE ((status)::text = 'failed'::text)
  • investigations_pkey: unique, btree (id)
  • investigations_request_id_key: unique, btree (request_id)

notify.channels​

ColumnTypeNullDefault
idbigintnonextval('notify.channels_id_seq'::regclass)
account_idbigintno
kindtextno
nametextno
target_sealedtextno
target_hinttextno
secret_sealedtextyes
enabledbooleannotrue
verified_attimestamp with time zoneyes
failing_sincetimestamp with time zoneyes
consecutive_failuresintegerno0
last_errortextyes
last_success_attimestamp with time zoneyes
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()

Indexes:

  • channels_pkey: unique, btree (id)
  • idx_notify_channels_account: btree (account_id, id)

notify.deliveries​

ColumnTypeNullDefault
idbigintnonextval('notify.deliveries_id_seq'::regclass)
account_idbigintno
event_iduuidyes
event_typetextno
channel_idbigintyes
channel_kindtextno
rule_idbigintyes
statustextno
attemptsintegerno0
last_errortextyes
not_beforetimestamp with time zoneyes
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()
sent_attimestamp with time zoneyes

Foreign keys:

  • deliveries_channel_id_fkey: FOREIGN KEY (channel_id) REFERENCES notify.channels(id) ON DELETE SET NULL
  • deliveries_event_id_fkey: FOREIGN KEY (event_id) REFERENCES notify.events(event_id) ON DELETE CASCADE
  • deliveries_rule_id_fkey: FOREIGN KEY (rule_id) REFERENCES notify.rules(id) ON DELETE SET NULL

Indexes:

  • deliveries_event_channel: unique, btree (event_id, channel_id)
  • deliveries_pkey: unique, btree (id)
  • idx_notify_deliveries_account: btree (account_id, created_at DESC, id DESC)
  • idx_notify_deliveries_channel: btree (channel_id, status)
  • idx_notify_deliveries_rule: btree (rule_id)
  • idx_notify_deliveries_tests: btree (created_at) WHERE (event_id IS NULL)

notify.events​

ColumnTypeNullDefault
event_iduuidno
account_idbigintno
typetextno
versionintegerno
producertextno
occurred_attimestamp with time zoneno
datajsonbno'{}'::jsonb
received_attimestamp with time zonenonow()

Indexes:

  • events_pkey: unique, btree (event_id)
  • idx_notify_events_account: btree (account_id)
  • idx_notify_events_received: btree (received_at)

notify.rule_channels​

ColumnTypeNullDefault
rule_idbigintno
channel_idbigintno

Foreign keys:

  • rule_channels_channel_id_fkey: FOREIGN KEY (channel_id) REFERENCES notify.channels(id) ON DELETE CASCADE
  • rule_channels_rule_id_fkey: FOREIGN KEY (rule_id) REFERENCES notify.rules(id) ON DELETE CASCADE

Indexes:

  • idx_notify_rule_channels_channel: btree (channel_id)
  • rule_channels_pkey: unique, btree (rule_id, channel_id)

notify.rules​

ColumnTypeNullDefault
idbigintnonextval('notify.rules_id_seq'::regclass)
account_idbigintno
nametextno
event_typestext[]no
enabledbooleannotrue
quiet_startsmallintyes
quiet_endsmallintyes
time_zonetextyes
min_interval_secondsintegerno0
created_attimestamp with time zonenonow()
updated_attimestamp with time zonenonow()

Indexes:

  • idx_notify_rules_account: btree (account_id, id)
  • rules_pkey: unique, btree (id)

Compatibility views​

Each moved table keeps a view in public with its old name, so a query that names no schema still reaches it. The views are security_invoker: the caller's grants on the table apply.

ViewTable
public.accountsidentity.accounts
public.agent_link_requestsidentity.agent_link_requests
public.agentsidentity.agents
public.ai_chat_messagesobservatory.ai_chat_messages
public.ai_chat_sessionsobservatory.ai_chat_sessions
public.ai_openrouter_credentialsobservatory.ai_openrouter_credentials
public.ai_reportsobservatory.ai_reports
public.ai_session_metadataobservatory.ai_session_metadata
public.ai_tool_call_argsobservatory.ai_tool_call_args
public.ai_tool_call_errorsobservatory.ai_tool_call_errors
public.ai_tool_callsobservatory.ai_tool_calls
public.ai_tool_confirmationsobservatory.ai_tool_confirmations
public.analytics_snapshotsruns.analytics_snapshots
public.api_tokensidentity.api_tokens
public.audit_eventsidentity.audit_events
public.backup_fix_commitsruns.backup_fix_commits
public.backup_fixesruns.backup_fixes
public.backup_result_errorsruns.backup_result_errors
public.backup_resultsruns.backup_results
public.backup_run_errorsruns.backup_run_errors
public.backup_run_fixesruns.backup_run_fixes
public.backup_run_requestsruns.backup_run_requests
public.backup_runsruns.backup_runs
public.embedding_chunk_metadataobservatory.embedding_chunk_metadata
public.embedding_chunksobservatory.embedding_chunks
public.embedding_generationsobservatory.embedding_generations
public.embedding_indexing_checkpointsobservatory.embedding_indexing_checkpoints
public.embedding_job_errorsobservatory.embedding_job_errors
public.embedding_jobsobservatory.embedding_jobs
public.execution_logsruns.execution_logs
public.investigation_errorsobservatory.investigation_errors
public.investigationsobservatory.investigations
public.research_samplesruns.research_samples
public.waitlist_signupsidentity.waitlist_signups
public.worker_repo_stateruns.worker_repo_state
public.worker_run_leaseruns.worker_run_lease