Skip to content

Database Schemas

Each service runs its own PostgreSQL database within the shared cluster. All table definitions live in numbered Goose SQL migration files under services/<name>/migrations/. Migrations run automatically on service startup via the shared github.com/olly/db package.

Migration Pattern

services/claims/migrations/
  0001_create_schema.sql     -- CREATE SCHEMA claims;
  0002_create_claims.sql     -- CREATE TABLE claims.claims (...)
  0003_create_claim_events.sql
  ...

Every file has a -- +goose Up block (applied forward) and a -- +goose Down block (rollback). Goose tracks applied migrations in a goose_db_version table within each service's schema. Adding a new table means adding a new numbered file — existing files are never edited after they are merged.


Claims

Database: claims

TableKey ColumnsPurpose
claims.claimsid, locator, policy_id, term_id, claimant_party_id, status, incident_date, document (JSONB)Core claim record; document holds flexible adjudication data
claims.claim_linesid, claim_id, line_number, element_id, coverage_term_key, amount_claimed, amount_allowed, amount_paid, reason_codeIndividual service lines within a claim
claims.claim_eventsid, claim_id, event_type, from_status, to_status, actor, noteImmutable audit trail of every status transition
claims.claim_documentsid, claim_id, filename, content_type, urlSupporting documents attached to a claim
claims.prior_authsid, locator, provider_id, policy_id, member_party_id, status, procedure_code, document (JSONB)Prior authorisation requests linked to a provider and policy
claims.outboxid, topic, key, payload (JSONB), published_atTransactional outbox for reliable Kafka publishing

Eligibility

Database: eligibility

TableKey ColumnsPurpose
eligibility.member_coverageid, party_id, policy_id, policy_element_id, element_static_id, term_id, product_code, element_type, coverage_terms (JSONB), status, effective_from, effective_toActive and historical coverage records per party per policy element
eligibility.coverage_accumulatorsid, party_id, term_id, accumulator_type, coverage_term_key, limit_amount, consumed_amount, currency, last_claim_locatorDeductible and out-of-pocket accumulator balances per coverage term
eligibility.projection_checkpointsconsumer_group, topic, partition, offsetKafka consumer offset checkpoints for the eligibility projection

Enrollment

Database: enrollment

TableKey ColumnsPurpose
enrollment.quotesid, locator, account_id, product_version_id, status, document (JSONB), expires_atDraft and finalised insurance quotes
enrollment.policiesid, locator, account_id, quote_id, product_version_id, status, inception_date, jurisdiction, region, document (JSONB)Issued policies derived from accepted quotes
enrollment.policy_termsid, locator, policy_id, term_number, effective_from, effective_to, statusAnnual or mid-term policy term periods
enrollment.policy_transactionsid, locator, policy_id, term_id, category, status, effective_date, document (JSONB)Endorsements, renewals, cancellations and other lifecycle events
enrollment.policy_elementsid, static_id, policy_id, term_id, element_type, document (JSONB)Individual coverage elements within a policy (e.g. medical, dental)
enrollment.underwriting_flagsid, policy_id, flag_type, value, created_atUnderwriting decisions and flags attached to a policy
enrollment.quote_field_valuesid, quote_id, field_def_id, valueDynamic field answers on a quote
enrollment.policy_field_valuesid, policy_id, field_def_id, valueDynamic field answers on a policy
enrollment.transaction_field_valuesid, transaction_id, field_def_id, valueDynamic field answers on a transaction
enrollment.outboxid, topic, key, payload (JSONB), published_atTransactional outbox for Kafka publishing

Billing

Database: billing

TableKey ColumnsPurpose
billing.chargesid, locator, policy_id, term_id, claim_id, account_id, category, amount, currency, status, charge_datePremium and claim charges to be invoiced
billing.invoicesid, locator, account_id, status, total_amount, currency, due_date, finalised_at, paid_atConsolidated invoices grouping charges for an account
billing.invoice_line_itemsid, invoice_id, charge_id, description, amountIndividual line items linking charges to an invoice
billing.paymentsid, locator, invoice_id, account_id, amount, currency, method, reference, status, settled_atPayment records against invoices
billing.adjustmentsid, locator, invoice_id, account_id, reason, amount, currencyCredit and debit adjustments to invoices
billing.ledger_entriesid, locator, account_id, policy_id, entry_type, reference_id, reference_type, direction, amount, currencyDouble-entry ledger for financial audit trail
billing.installmentsid, locator, invoice_id, due_date, amount, statusInstalment schedules for deferred payment plans
billing.projection_checkpointsconsumer_group, topic, partition, offsetKafka consumer offset checkpoints
billing.outboxid, topic, key, payload (JSONB), published_atTransactional outbox for Kafka publishing

Provider

Database: provider

TableKey ColumnsPurpose
provider.providersid, locator, npi, party_id, party_locator, name, specialty, network_status, address (JSONB), phone, email, activated_atProvider directory; network_status drives in-/out-of-network adjudication
provider.credentialing_requestsid, locator, provider_id, status, submitted_at, reviewed_at, reviewer_notesCredentialing workflow records; provider is not activated until approved

Notifications

Database: notifications

TableKey ColumnsPurpose
notifications.notification_preferencesid, party_id, party_locator, email, phone, preferred_channel, opted_out_events (JSONB)Per-party channel preferences and opt-out lists
notifications.notification_logid, locator, event_id, party_id, event_type, channel, status, subject, body, failure_reason, attempt_count, sent_atDelivery audit log for every notification attempt
notifications.projection_checkpointsconsumer_group, topic, partition, offsetKafka consumer offset checkpoints

Policy Admin

Database: policy_admin

TableKey ColumnsPurpose
policy_admin.partiesid, locator, type (INDIVIDUAL/ORGANISATION/PROVIDER), first_name, last_name, name, email, phone, address (JSONB), date_of_birthCentral party registry — all people and organisations in the system
policy_admin.party_rolesid, party_id, role_type, locatorRole assignments linking parties to accounts and policies
policy_admin.productsid, locator, code, name, lob, statusInsurance product definitions
policy_admin.product_versionsid, product_id, version, effective_from, effective_to, document (JSONB)Versioned product configurations
policy_admin.rule_setsid, product_version_id, name, rule_set_typeGroupings of underwriting and pricing rules
policy_admin.rulesid, rule_set_id, condition, action, priorityIndividual rule definitions
policy_admin.rule_evaluationsid, rule_set_id, entity_id, result, evaluated_atStored results of rule evaluations
policy_admin.accountsid, locator, name, billing_level (ACCOUNT/POLICY), currency, display_numberBilling accounts grouping one or more policies
policy_admin.market_profilesid, market_code, currency, jurisdiction, document (JSONB)Market-specific configuration (UK, US, etc.)
policy_admin.field_definitionsid, product_version_id, field_key, field_type, required, options (JSONB)Dynamic field schema for quotes and policies

Database: consent

TableKey ColumnsPurpose
consent.consent_recordsid, party_locator, consent_type, grantedPer-party per-consent-type grant/deny state; unique on (party_locator, consent_type)
consent.consent_auditid, party_locator, consent_type, granted, changed_by, changed_atImmutable audit trail of every consent state change
consent.deletion_requestsid, party_locator, delete_type, status, requested_by_type, reason, requested_at, completed_at, attempt_countGDPR/right-to-erasure deletion requests with processing state

Document Service

Database: documents

TableKey ColumnsPurpose
documents.templatesid, market_code, template_type, content_html; unique on (market_code, template_type)HTML templates for generated documents (policies, EOBs, letters)
documents.documentsid, locator, party_locator, template_type, market_code, content (BYTEA)Generated document blobs stored in-DB (S3 in production)
documents.outboxid, event_type, payload (JSONB), published_atTransactional outbox for Kafka publishing

Triage

Database: triage

TableKey ColumnsPurpose
triage.sessionsid, locator, party_locator, status, chief_complaint, severity, recommendation (JSONB), consent_verified_at, completed_atAI-assisted triage sessions initiated by a member
triage.turnsid, locator, session_locator, role, question_type, contentIndividual conversational turns within a triage session

Care

Database: care (no explicit schema prefix — tables created in the default care database)

TableKey ColumnsPurpose
episodesid, locator, party_locator, triage_session_locator, care_type, status, summaryCare episodes grouping appointments and prescriptions for a health event
provider_slotsid, locator, provider_locator, start_time, end_time, status, appointment_locatorAvailable provider appointment slots
appointmentsid, locator, episode_locator, provider_locator, type, status, slot_locator, link_out_url, scheduled_at, notesScheduled appointments within a care episode
prescriptionsid, locator, episode_locator, provider_locator, medication (JSONB), status, issued_atPrescriptions issued during a care episode
diagnostics_referralsid, locator, episode_locator, referral_type, clinic_locator, status, appointment_locatorDiagnostic and specialist referrals

Group Scheme Service

Database: group_scheme

TableKey ColumnsPurpose
group_scheme.schemesid, locator, code, name, employer_party_locator, statusEmployer group schemes
group_scheme.scheme_membersid, scheme_id, member_party_locator, policy_locator, statusMembers enrolled under a group scheme; unique on (scheme_id, member_party_locator)
group_scheme.bulk_enrollment_jobsid, locator, scheme_id, status, total, processed, failed_count, errors (JSONB)Async bulk enrollment job tracking

Broker API

Database: broker_api

TableKey ColumnsPurpose
broker_api.broker_configsid, locator, broker_id, delegated_authority_limit; unique on broker_idBroker configuration including delegated authority limits
broker_api.commissionsid, locator, broker_id, policy_locator, rate, amount, status (PENDING/PAID)Commission records for policies placed by a broker

Olly Health Insurance Platform