Postgres Schema

Status: Stub — content pending.

Status: Stub — content pending.


title: "Postgres Schema" description: "All Postgres tables used by obleth, their columns, and the migration file that introduced each."

obleth uses SQLx with embedded migrations. Migrations run automatically on startup and are idempotent.

Tables

tenants

Stores all tenants. Introduced in migration 0001.

ColumnTypeNotes
idUUID PRIMARY KEYgen_random_uuid()
nameTEXT NOT NULL UNIQUEHuman-readable name
weightBIGINT NOT NULL DEFAULT 100Fairshare weight
tokens_per_minuteBIGINT NOT NULL DEFAULT 0TPM quota (0 = unlimited)
group_nameTEXTFairshare group assignment
created_atTIMESTAMPTZAuto-set
updated_atTIMESTAMPTZAuto-updated

api_keys

Stores API key hashes. The raw key is never stored. Introduced in 0001.

ColumnTypeNotes
idUUID PRIMARY KEY
tenant_idUUID NOT NULLFK → tenants.id
nameTEXT NOT NULLDisplay name
key_hashTEXT NOT NULL UNIQUESHA-256 of the full secret
key_prefixTEXT NOT NULLFirst 18 chars (safe to display)
disabledBOOLEAN NOT NULL DEFAULT false
created_atTIMESTAMPTZ
updated_atTIMESTAMPTZ

models

Model registry. Introduced in 0002; cache_enabled/cache_ttl_secs added in 0004.

ColumnTypeNotes
idUUID PRIMARY KEY
model_nameTEXT NOT NULL UNIQUEName used in client requests
upstream_modelTEXTModel name sent to upstream
api_baseTEXTPer-model upstream override
api_keyTEXTInjected upstream credential
input_cost_per_tokenFLOAT8For billing
output_cost_per_tokenFLOAT8For billing
context_windowBIGINT
admission_weightFLOAT8 DEFAULT 1.0Scales fairshare cost
supports_function_callingBOOLEAN
supports_system_messagesBOOLEAN
enabledBOOLEAN DEFAULT true
cache_enabledBOOLEAN DEFAULT falseResponse cache toggle
cache_ttl_secsBIGINTCache TTL
created_atTIMESTAMPTZ
updated_atTIMESTAMPTZ

fairshare_groups

Scheduler groups for hierarchical mode. Introduced in 0003.

ColumnTypeNotes
nameTEXT PRIMARY KEYGroup name
weightBIGINT NOT NULL DEFAULT 100Group-level weight
created_atTIMESTAMPTZ

mcp_servers

MCP server registry. Introduced in 0005.

ColumnTypeNotes
idUUID PRIMARY KEY
nameTEXT NOT NULL UNIQUE
base_urlTEXT NOT NULL
auth_headerTEXTInjected auth header value
enabledBOOLEAN DEFAULT true
created_atTIMESTAMPTZ
updated_atTIMESTAMPTZ

audit_log

Immutable record of all Management API mutations. Introduced in 0001.

ColumnTypeNotes
idUUID PRIMARY KEY
actionTEXT NOT NULLe.g. create_tenant, delete_key
entity_typeTEXT NOT NULLe.g. tenant, api_key
entity_idTEXTUUID of the affected entity
payloadJSONBBefore/after snapshot
created_atTIMESTAMPTZ

Migrations

Migrations live in obleth-config/migrations/ and are embedded in the binary. They run in order on startup. You can inspect the applied migrations:

SELECT filename, installed_on
FROM _sqlx_migrations
ORDER BY installed_on;