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
| Column | Type | Null | Default |
|---|---|---|---|
key | text | no | |
value | bytea | no | |
expires_at | timestamp with time zone | no |
Indexes:
idx_platform_cache_expires: btree (expires_at)platform_cache_pkey: unique, btree (key)
public.platform_jobs
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('platform_jobs_id_seq'::regclass) |
kind | text | no | |
key | text | yes | |
payload | bytea | no | '\x'::bytea |
state | text | no | 'waiting'::text |
attempts | integer | no | 0 |
max_attempts | integer | no | |
run_at | timestamp with time zone | no | now() |
lease_until | timestamp with time zone | yes | |
token | text | yes | |
last_error | text | yes | |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
name | text | no | |
holder | text | no | |
expires_at | timestamp with time zone | no |
Indexes:
platform_locks_pkey: unique, btree (name)
public.platform_rate_limits
| Column | Type | Null | Default |
|---|---|---|---|
key | text | no | |
count | integer | no | |
expires_at | timestamp with time zone | no |
Indexes:
idx_platform_rate_limits_expires: btree (expires_at)platform_rate_limits_pkey: unique, btree (key)
public.schema_migrations
| Column | Type | Null | Default |
|---|---|---|---|
version | bigint | no | |
name | character varying(255) | no | |
dirty | boolean | no | false |
applied_at | timestamp with time zone | no | now() |
Indexes:
schema_migrations_pkey: unique, btree (version)
identity.accounts
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('identity.accounts_id_seq'::regclass) |
github_user_id | bigint | yes | |
github_login | text | yes | |
display_name | text | yes | |
email | text | yes | |
plan | text | no | 'none'::text |
is_owner | boolean | no | false |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
disabled_at | timestamp with time zone | yes | |
research_opt_in_at | timestamp with time zone | yes | |
plan_version | bigint | no | 0 |
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
identity.agent_link_requests
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('identity.agent_link_requests_id_seq'::regclass) |
device_code_hash | bytea | no | |
user_code | text | no | |
agent_name | text | no | |
hostname | text | yes | |
version | text | yes | |
status | text | no | 'pending'::text |
account_id | bigint | yes | |
created_at | timestamp with time zone | no | now() |
expires_at | timestamp with time zone | no | |
approved_at | timestamp with time zone | yes | |
last_polled_at | timestamp with time zone | yes |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('identity.agents_id_seq'::regclass) |
account_id | bigint | no | |
name | text | no | |
hostname | text | yes | |
version | text | yes | |
created_at | timestamp with time zone | no | now() |
last_seen_at | timestamp with time zone | yes | |
revoked_at | timestamp with time zone | yes |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('identity.api_tokens_id_seq'::regclass) |
account_id | bigint | no | |
kind | text | no | |
agent_id | bigint | yes | |
name | text | no | |
token_hash | bytea | no | |
display | text | no | |
scopes | text[] | no | |
created_at | timestamp with time zone | no | now() |
last_used_at | timestamp with time zone | yes | |
expires_at | timestamp with time zone | yes | |
revoked_at | timestamp with time zone | yes |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('identity.audit_events_id_seq'::regclass) |
account_id | bigint | yes | |
actor | text | no | |
action | text | no | |
target | text | yes | |
detail | jsonb | no | '{}'::jsonb |
created_at | timestamp with time zone | no | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('identity.outbox_id_seq'::regclass) |
event_id | uuid | no | gen_random_uuid() |
type | text | no | |
version | integer | no | |
account_id | bigint | no | |
dedup_key | text | no | |
occurred_at | timestamp with time zone | no | now() |
data | jsonb | no | '{}'::jsonb |
published_at | timestamp with time zone | yes |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('identity.revocations_id_seq'::regclass) |
token_id | bigint | yes | |
agent_id | bigint | yes | |
account_id | bigint | yes | |
at | timestamp with time zone | no | clock_timestamp() |
Indexes:
idx_revocations_at: btree (at)revocations_pkey: unique, btree (id)
identity.waitlist_signups
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('identity.waitlist_signups_id_seq'::regclass) |
email | text | no | |
source | text | no | 'landing'::text |
created_at | timestamp with time zone | no | now() |
Indexes:
idx_waitlist_signups_email: unique, btree (lower(email))waitlist_signups_pkey: unique, btree (id)
runs.account_versions
| Column | Type | Null | Default |
|---|---|---|---|
account_id | bigint | no | |
runs_version | bigint | no | 0 |
requests_version | bigint | no | 0 |
updated_at | timestamp with time zone | no | now() |
Indexes:
account_versions_pkey: unique, btree (account_id)
runs.analytics_snapshots
| Column | Type | Null | Default |
|---|---|---|---|
run_id | integer | no | |
captured_at | timestamp with time zone | yes | now() |
head_commit | text | yes | ''::text |
head_commit_message | text | yes | ''::text |
head_commit_at | timestamp with time zone | yes | |
total_commits | integer | yes | 0 |
branch_count | integer | yes | 0 |
tag_count | integer | yes | 0 |
tracked_files | integer | yes | 0 |
total_blob_size_bytes | bigint | yes | 0 |
avg_blob_size_bytes | bigint | yes | 0 |
largest_blob_path | text | yes | ''::text |
largest_blob_size_bytes | bigint | yes | 0 |
archive_count | integer | yes | 0 |
total_archive_size_bytes | bigint | yes | 0 |
avg_archive_size_bytes | bigint | yes | 0 |
largest_archive_path | text | yes | ''::text |
largest_archive_size_bytes | bigint | yes | 0 |
account_id | bigint | no |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | integer | no | nextval('runs.backup_fix_commits_id_seq'::regclass) |
fix_id | integer | no | |
commit_hash | text | no | |
created_at | timestamp with time zone | yes | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | integer | no | nextval('runs.backup_fixes_id_seq'::regclass) |
title | text | no | |
description | text | no | ''::text |
author | text | yes | ''::text |
created_at | timestamp with time zone | yes | now() |
updated_at | timestamp with time zone | yes | now() |
account_id | bigint | no | |
idempotency_key | text | yes | |
request_sha256 | bytea | yes | |
recorded_by | text | yes |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | integer | no | nextval('runs.backup_result_errors_id_seq'::regclass) |
result_id | integer | no | |
error_message | text | no | |
created_at | timestamp with time zone | yes | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | integer | no | nextval('runs.backup_results_id_seq'::regclass) |
run_id | integer | yes | |
repo_full_name | text | no | |
status | text | no | 'pending'::text |
commit_hash | text | yes | ''::text |
archive_size_bytes | bigint | yes | 0 |
duration_ms | bigint | yes | 0 |
created_at | timestamp with time zone | yes | now() |
account_id | bigint | no | |
reason_code | text | yes | |
stat_outcome | text | yes | |
clone_ms | bigint | yes | |
pack_ms | bigint | yes | |
upload_ms | bigint | yes | |
cloned_bytes | bigint | yes |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | integer | no | nextval('runs.backup_run_errors_id_seq'::regclass) |
run_id | integer | no | |
error_message | text | no | |
created_at | timestamp with time zone | yes | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
run_id | integer | no | |
fix_id | integer | no |
Foreign keys:
backup_run_fixes_fix_id_fkey: FOREIGN KEY (fix_id) REFERENCES runs.backup_fixes(id) ON DELETE CASCADEbackup_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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('runs.backup_run_requests_id_seq'::regclass) |
target_repo | text | yes | |
requested_by | text | no | |
reason | text | yes | |
status | text | no | 'pending'::text |
run_id | bigint | yes | |
created_at | timestamp with time zone | no | now() |
started_at | timestamp with time zone | yes | |
finished_at | timestamp with time zone | yes | |
account_id | bigint | no |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | integer | no | nextval('runs.backup_runs_id_seq'::regclass) |
status | text | no | 'running'::text |
started_at | timestamp with time zone | yes | now() |
completed_at | timestamp with time zone | yes | |
total_repos | integer | yes | 0 |
successful | integer | yes | 0 |
failed | integer | yes | 0 |
skipped | integer | yes | 0 |
duration_ms | bigint | yes | 0 |
full_run | boolean | no | true |
account_id | bigint | no | |
telemetry | jsonb | yes | |
agent_version | text | yes | |
agent_os | text | yes | |
sink_type | text | yes |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('runs.execution_logs_id_seq'::regclass) |
run_id | integer | yes | |
level | text | no | 'info'::text |
message | text | no | |
repository | text | yes | ''::text |
created_at | timestamp with time zone | yes | now() |
account_id | bigint | no |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('runs.outbox_id_seq'::regclass) |
event_id | uuid | no | gen_random_uuid() |
type | text | no | |
version | integer | no | |
account_id | bigint | no | |
dedup_key | text | no | |
occurred_at | timestamp with time zone | no | now() |
data | jsonb | no | '{}'::jsonb |
published_at | timestamp with time zone | yes |
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)
runs.research_consent
| Column | Type | Null | Default |
|---|---|---|---|
account_id | bigint | no | |
opted_in_at | timestamp with time zone | yes | |
updated_at | timestamp with time zone | no | now() |
Indexes:
research_consent_pkey: unique, btree (account_id)
runs.research_samples
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('runs.research_samples_id_seq'::regclass) |
account_id | bigint | no | |
run_id | integer | yes | |
repo_id | text | no | |
reason_code | text | no | |
status | text | yes | |
stat_outcome | text | yes | |
prior_pushed_at | timestamp with time zone | yes | |
pushed_at | timestamp with time zone | yes | |
size_bucket | text | no | |
cloned_bytes | bigint | yes | |
archive_bytes | bigint | yes | |
clone_ms | bigint | yes | |
pack_ms | bigint | yes | |
upload_ms | bigint | yes | |
shadow_head | text | yes | |
shadow_refs | text | yes | |
shadow_error | text | yes | |
agent_version | text | yes | |
agent_os | text | yes | |
sink_type | text | yes | |
created_at | timestamp with time zone | no | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
repo_full_name | text | no | |
display_name | text | no | |
private | boolean | no | false |
pushed_at | timestamp with time zone | yes | |
archive_format | text | no | |
archive_key | text | yes | |
archive_sha256 | text | yes | |
archive_size_bytes | bigint | yes | |
status | text | no | |
last_error | text | yes | |
last_attempt_at | timestamp with time zone | yes | |
last_backed_up_at | timestamp with time zone | yes | |
missing_since | timestamp with time zone | yes | |
updated_at | timestamp with time zone | no | now() |
account_id | bigint | no |
Indexes:
worker_repo_state_pkey: unique, btree (account_id, repo_full_name)
runs.worker_run_lease
| Column | Type | Null | Default |
|---|---|---|---|
lease_name | text | no | |
holder | text | no | |
acquired_at | timestamp with time zone | no | |
heartbeat_at | timestamp with time zone | no | |
expires_at | timestamp with time zone | no | |
account_id | bigint | no |
Indexes:
worker_run_lease_pkey: unique, btree (account_id, lease_name)
insights.account_rollups
| Column | Type | Null | Default |
|---|---|---|---|
account_id | bigint | no | |
source_version | bigint | no | |
runs | bigint | no | |
successful | bigint | no | |
failed | bigint | no | |
skipped | bigint | no | |
total_repos | bigint | no | |
duration_ms_sum | bigint | no | |
duration_ms_count | bigint | no | |
distinct_repos | bigint | no | |
total_size_bytes | bigint | no | |
largest_archive_bytes | bigint | no | |
largest_repository | text | no | |
computed_at | timestamp with time zone | no | now() |
Indexes:
account_rollups_pkey: unique, btree (account_id)
billing.cohorts
| Column | Type | Null | Default |
|---|---|---|---|
id | text | no | |
plan_id | text | no | |
name | text | no | |
position | integer | no | |
seats | integer | yes |
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
| Column | Type | Null | Default |
|---|---|---|---|
account_id | bigint | no | |
name | text | no | |
email | text | no | |
country | text | no | |
state | text | yes | |
gstin | text | yes | |
address | text | no | ''::text |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
Indexes:
customers_pkey: unique, btree (account_id)
billing.document_sequences
| Column | Type | Null | Default |
|---|---|---|---|
series | text | no | |
financial_year | text | no | |
last | integer | no | 0 |
Indexes:
document_sequences_pkey: unique, btree (series, financial_year)
billing.entitlement_versions
| Column | Type | Null | Default |
|---|---|---|---|
account_id | bigint | no | |
version | bigint | no | 0 |
Indexes:
entitlement_versions_pkey: unique, btree (account_id)
billing.invoices
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('billing.invoices_id_seq'::regclass) |
number | text | no | |
account_id | bigint | no | |
payment_id | bigint | no | |
issued_at | timestamp with time zone | no | now() |
currency | text | no | |
total_minor | bigint | no | |
taxable_minor | bigint | no | |
tax_minor | bigint | no | |
tax_rate_bps | integer | no | |
tax_kind | text | no | |
seller | jsonb | no | |
buyer | jsonb | no | |
lines | jsonb | no |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('billing.outbox_id_seq'::regclass) |
event_id | uuid | no | gen_random_uuid() |
type | text | no | |
version | integer | no | |
account_id | bigint | no | |
dedup_key | text | no | |
occurred_at | timestamp with time zone | no | now() |
data | jsonb | no | '{}'::jsonb |
published_at | timestamp with time zone | yes |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('billing.payments_id_seq'::regclass) |
account_id | bigint | no | |
subscription_id | bigint | no | |
provider | text | no | |
provider_ref | text | no | |
amount_minor | bigint | no | |
currency | text | no | |
status | text | no | |
method | text | no | ''::text |
failure_reason | text | no | ''::text |
paid_at | timestamp with time zone | yes | |
created_at | timestamp with time zone | no | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | text | no | |
name | text | no | |
description | text | no | ''::text |
entitles | text | no | |
position | integer | no | 0 |
active | boolean | no | true |
created_at | timestamp with time zone | no | now() |
Indexes:
plans_pkey: unique, btree (id)
billing.prices
| Column | Type | Null | Default |
|---|---|---|---|
id | text | no | |
cohort_id | text | no | |
currency | text | no | |
amount_minor | bigint | no | |
mode | text | no | |
period | text | no | 'year'::text |
tax_inclusive | boolean | no | true |
active | boolean | no | true |
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
| Column | Type | Null | Default |
|---|---|---|---|
provider | text | no | |
kind | text | no | |
local_id | text | no | |
external_id | text | no | |
created_at | timestamp with time zone | no | now() |
Indexes:
provider_refs_pkey: unique, btree (provider, kind, local_id)
billing.refunds
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('billing.refunds_id_seq'::regclass) |
account_id | bigint | no | |
payment_id | bigint | no | |
provider | text | no | |
provider_ref | text | yes | |
amount_minor | bigint | no | |
fee_minor | bigint | no | |
status | text | no | 'requested'::text |
credit_note_number | text | yes | |
requested_at | timestamp with time zone | no | now() |
processed_at | timestamp with time zone | yes |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('billing.subscriptions_id_seq'::regclass) |
account_id | bigint | no | |
price_id | text | no | |
provider | text | no | |
provider_ref | text | yes | |
mode | text | no | |
status | text | no | 'pending'::text |
checkout_url | text | yes | |
checkout_expires_at | timestamp with time zone | yes | |
current_period_start | timestamp with time zone | yes | |
current_period_end | timestamp with time zone | yes | |
activated_at | timestamp with time zone | yes | |
ended_at | timestamp with time zone | yes | |
renews_id | bigint | yes | |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
provider | text | no | |
event_id | text | no | |
type | text | no | |
received_at | timestamp with time zone | no | now() |
processed_at | timestamp with time zone | yes | |
payload | jsonb | yes |
Indexes:
idx_webhook_events_received: btree (received_at)webhook_events_pkey: unique, btree (provider, event_id)
observatory.ai_chat_messages
| Column | Type | Null | Default |
|---|---|---|---|
id | uuid | no | |
session_id | uuid | yes | |
request_id | uuid | no | |
role | character varying | no | |
content | text | no | |
created_at | timestamp with time zone | no | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | uuid | no | |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
session_name | character varying | yes | |
account_id | bigint | no |
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
| Column | Type | Null | Default |
|---|---|---|---|
username | text | no | |
key_ciphertext | text | no | |
key_hint | text | no | |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
last_used_at | timestamp with time zone | yes | |
invalid_at | timestamp with time zone | yes | |
account_id | bigint | yes |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | uuid | no | |
report_type | character varying | no | |
subject | character varying | no | |
recipients | jsonb | no | |
content_html | text | yes | |
content_markdown | text | yes | |
status | character varying | no | |
pdf_path | character varying | yes | |
error_message | text | yes | |
sent_at | timestamp with time zone | yes | |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
account_id | bigint | no |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | uuid | no | |
session_id | uuid | no | |
metadata | jsonb | no | |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | uuid | no | |
tool_call_id | uuid | no | |
args | jsonb | no | |
created_at | timestamp with time zone | no | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | uuid | no | |
tool_call_id | uuid | no | |
error | text | no | |
created_at | timestamp with time zone | no | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | uuid | no | |
request_id | uuid | no | |
name | character varying | no | |
result | jsonb | yes | |
success | boolean | no | |
duration_ms | double precision | yes | |
created_at | timestamp with time zone | no | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
confirm_id | uuid | no | |
session_id | uuid | yes | |
request_id | uuid | yes | |
username | text | no | |
tool_name | text | no | |
args | jsonb | no | '{}'::jsonb |
status | text | no | 'pending'::text |
created_at | timestamp with time zone | no | now() |
decided_at | timestamp with time zone | yes | |
account_id | bigint | no |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | integer | no | nextval('observatory.embedding_chunk_metadata_id_seq'::regclass) |
chunk_id | integer | no | |
metadata | jsonb | no | '{}'::jsonb |
created_at | timestamp with time zone | yes | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | integer | no | nextval('observatory.embedding_chunks_id_seq'::regclass) |
generation_id | integer | no | |
source_type | text | no | |
source_id | text | no | |
chunk_index | integer | no | 0 |
content | text | no | |
content_hash | text | no | |
embedding | vector | yes | |
content_tsv | tsvector | yes | to_tsvector('english'::regconfig, content) |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
account_id | bigint | no |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | integer | no | nextval('observatory.embedding_generations_id_seq'::regclass) |
model_id | text | no | |
dimensions | integer | no | |
status | text | no | 'BUILDING'::text |
created_at | timestamp with time zone | no | now() |
activated_at | timestamp with time zone | yes | |
completed_at | timestamp with time zone | yes | |
retired_at | timestamp with time zone | yes | |
total_items | integer | no | 0 |
processed_items | integer | no | 0 |
failed_items | integer | no | 0 |
backfill_started_at | timestamp with time zone | yes | |
backfill_completed_at | timestamp with time zone | yes |
Indexes:
embedding_generations_pkey: unique, btree (id)idx_embedding_generations_single_active: unique, btree (status) WHERE (status = 'ACTIVE'::text)
observatory.embedding_indexing_checkpoints
| Column | Type | Null | Default |
|---|---|---|---|
source_type | text | no | |
last_indexed_id | bigint | no | 0 |
updated_at | timestamp with time zone | no | now() |
Indexes:
embedding_indexing_checkpoints_pkey: unique, btree (source_type)
observatory.embedding_job_errors
| Column | Type | Null | Default |
|---|---|---|---|
id | integer | no | nextval('observatory.embedding_job_errors_id_seq'::regclass) |
job_id | bigint | no | |
error_message | text | no | |
created_at | timestamp with time zone | yes | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('observatory.embedding_jobs_id_seq'::regclass) |
generation_id | integer | no | |
source_type | text | no | |
source_id | text | no | |
content_hash | text | no | ''::text |
status | text | no | 'pending'::text |
attempt_count | integer | no | 0 |
max_attempts | integer | no | 3 |
claimed_at | timestamp with time zone | yes | |
completed_at | timestamp with time zone | yes | |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
account_id | bigint | yes | |
content | text | yes | |
metadata | jsonb | yes |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | uuid | no | |
investigation_id | uuid | no | |
error | text | no | |
created_at | timestamp with time zone | no | now() |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | uuid | no | |
request_id | uuid | no | |
session_id | uuid | yes | |
question | text | no | |
answer | text | yes | |
tool_calls | jsonb | no | |
tool_results | jsonb | no | |
status | character varying | no | |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
account_id | bigint | no |
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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('notify.channels_id_seq'::regclass) |
account_id | bigint | no | |
kind | text | no | |
name | text | no | |
target_sealed | text | no | |
target_hint | text | no | |
secret_sealed | text | yes | |
enabled | boolean | no | true |
verified_at | timestamp with time zone | yes | |
failing_since | timestamp with time zone | yes | |
consecutive_failures | integer | no | 0 |
last_error | text | yes | |
last_success_at | timestamp with time zone | yes | |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
Indexes:
channels_pkey: unique, btree (id)idx_notify_channels_account: btree (account_id, id)
notify.deliveries
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('notify.deliveries_id_seq'::regclass) |
account_id | bigint | no | |
event_id | uuid | yes | |
event_type | text | no | |
channel_id | bigint | yes | |
channel_kind | text | no | |
rule_id | bigint | yes | |
status | text | no | |
attempts | integer | no | 0 |
last_error | text | yes | |
not_before | timestamp with time zone | yes | |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
sent_at | timestamp with time zone | yes |
Foreign keys:
deliveries_channel_id_fkey: FOREIGN KEY (channel_id) REFERENCES notify.channels(id) ON DELETE SET NULLdeliveries_event_id_fkey: FOREIGN KEY (event_id) REFERENCES notify.events(event_id) ON DELETE CASCADEdeliveries_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
| Column | Type | Null | Default |
|---|---|---|---|
event_id | uuid | no | |
account_id | bigint | no | |
type | text | no | |
version | integer | no | |
producer | text | no | |
occurred_at | timestamp with time zone | no | |
data | jsonb | no | '{}'::jsonb |
received_at | timestamp with time zone | no | now() |
Indexes:
events_pkey: unique, btree (event_id)idx_notify_events_account: btree (account_id)idx_notify_events_received: btree (received_at)
notify.rule_channels
| Column | Type | Null | Default |
|---|---|---|---|
rule_id | bigint | no | |
channel_id | bigint | no |
Foreign keys:
rule_channels_channel_id_fkey: FOREIGN KEY (channel_id) REFERENCES notify.channels(id) ON DELETE CASCADErule_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
| Column | Type | Null | Default |
|---|---|---|---|
id | bigint | no | nextval('notify.rules_id_seq'::regclass) |
account_id | bigint | no | |
name | text | no | |
event_types | text[] | no | |
enabled | boolean | no | true |
quiet_start | smallint | yes | |
quiet_end | smallint | yes | |
time_zone | text | yes | |
min_interval_seconds | integer | no | 0 |
created_at | timestamp with time zone | no | now() |
updated_at | timestamp with time zone | no | now() |
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.
| View | Table |
|---|---|
public.accounts | identity.accounts |
public.agent_link_requests | identity.agent_link_requests |
public.agents | identity.agents |
public.ai_chat_messages | observatory.ai_chat_messages |
public.ai_chat_sessions | observatory.ai_chat_sessions |
public.ai_openrouter_credentials | observatory.ai_openrouter_credentials |
public.ai_reports | observatory.ai_reports |
public.ai_session_metadata | observatory.ai_session_metadata |
public.ai_tool_call_args | observatory.ai_tool_call_args |
public.ai_tool_call_errors | observatory.ai_tool_call_errors |
public.ai_tool_calls | observatory.ai_tool_calls |
public.ai_tool_confirmations | observatory.ai_tool_confirmations |
public.analytics_snapshots | runs.analytics_snapshots |
public.api_tokens | identity.api_tokens |
public.audit_events | identity.audit_events |
public.backup_fix_commits | runs.backup_fix_commits |
public.backup_fixes | runs.backup_fixes |
public.backup_result_errors | runs.backup_result_errors |
public.backup_results | runs.backup_results |
public.backup_run_errors | runs.backup_run_errors |
public.backup_run_fixes | runs.backup_run_fixes |
public.backup_run_requests | runs.backup_run_requests |
public.backup_runs | runs.backup_runs |
public.embedding_chunk_metadata | observatory.embedding_chunk_metadata |
public.embedding_chunks | observatory.embedding_chunks |
public.embedding_generations | observatory.embedding_generations |
public.embedding_indexing_checkpoints | observatory.embedding_indexing_checkpoints |
public.embedding_job_errors | observatory.embedding_job_errors |
public.embedding_jobs | observatory.embedding_jobs |
public.execution_logs | runs.execution_logs |
public.investigation_errors | observatory.investigation_errors |
public.investigations | observatory.investigations |
public.research_samples | runs.research_samples |
public.waitlist_signups | identity.waitlist_signups |
public.worker_repo_state | runs.worker_repo_state |
public.worker_run_lease | runs.worker_run_lease |