Skip to content

Opensure Insurance Schema v2.2.1

Complete database schema for multi-tenant insurance operations.

Version: 2.2.1 Release Date: 2025-11-25 Total Tables: 42 (35 existing + 7 new) Total Columns: 571

What's New in v2.2.1

New Tables (+7)

TableColumnsPurpose
client_locations22Client property locations for multi-location risk tracking
client_notes9User notes attached to clients
clients_chat13LLM chat history for clients (placeholder)
marketfinder_clients36Prospects from Chrome Extension before conversion
marketfinder_client_locations22Property locations for MarketFinder prospects
marketfinder_clients_notes9User notes for prospects (copied on conversion)
marketfinder_clients_chat13LLM chat history (NOT copied on conversion)
  • audit_logs: +1 (correlation_id)
  • clients: +4 (client_type, website, primary_contact_id, source_system)
  • policies: +10 (program_id, product_code, bound_at, quote_expires_at, source_channel, broker_reference, lender_reference, currency_code, external_ref, source_system)
  • policy_coverages: +2 (sort_order, section_code)
  • policy_risks: +2 (client_location_id, sort_order)
  • invoices: +5 (balance_due, written_off_amount, last_reminder_at, external_ref, source_system)
  • invoice_items: +3 (tax_code, gl_account_code, quantity)
  • invoice_payments: +3 (currency_code, fx_rate, original_currency_code)
  • reinsurers: +1 (external_ref)
  • reinsurance_agreements: +4 (reinsurer_id, reinsurance_broker_id, agreement_number, currency_code)
  • policy_cessions: +2 (ceded_commission, currency_code)
  • uw_submissions: +7 (status, submitted_at, updated_at, underwriter_id, decline_reason, source_channel, target_carrier_id)
  • tasks: +2 (completed_at, completed_by)
  • consents: +3 (ip_address, user_agent, document_hash)
  • claims: +6 (closed_at, loss_location_id, reported_by_contact_id, cat_event_code, external_ref, source_system)
  • claim_reserves: +3 (currency_code, reserve_type, coverage_id)
  • claim_payments: +3 (currency_code, coverage_id, funding_source)
  • claim_recoveries: +1 (currency_code)
  • claim_parties: +2 (organization_name, policy_role)

MarketFinder Conversion Flow

When a prospect is converted to a client:

marketfinder_clients          → clients                 (COPY)
marketfinder_client_locations → client_locations        (COPY)
marketfinder_clients_notes    → client_notes            (COPY)
marketfinder_clients_chat     → clients_chat            (NOT COPIED - stays in MarketFinder)

Chat history remains with the prospect record for audit purposes.


Schema Overview

Core Tables

TablePurpose
audit_logsImmutable audit trail for compliance
clientsPolicyholders and customers
policiesInsurance policies
claimsInsurance claims with loss details

Policy Extensions

TablePurpose
policy_coveragesCoverage limits and deductibles
policy_exclusionsPolicy exclusions and limitations
policy_risksExposures/risks (property, vehicles, trips)
policy_risk_propertiesProperty-specific risk details
policy_risk_vehiclesVehicle-specific risk details
policy_risk_tripsTravel-specific risk details
policy_endorsementsMid-term adjustments
policy_renewalsRenewal tracking
policy_cancellationsCancellation tracking
policy_dependentsLife/health dependents
policy_beneficiariesLife insurance beneficiaries
policy_documentsPolicy-level documents
policy_cessionsReinsurance cessions

Billing & Invoicing

TablePurpose
invoicesBilling invoices
invoice_itemsLine items
invoice_paymentsPayment records

Claims Management

TablePurpose
claim_status_historyImmutable status change log
claim_reservesFinancial reserves
claim_paymentsPayment ledger
claim_recoveriesSubrogation/salvage recoveries
claim_partiesAdditional parties (witnesses, attorneys)
claim_documentsClaim attachments
claim_notesInternal/external notes

Underwriting

TablePurpose
uw_submissionsSubmissions and questionnaires
uw_scoresScores and decisions

Reinsurance

TablePurpose
reinsurersReinsurance companies
reinsurance_agreementsTreaties and facultative agreements

Operations

TablePurpose
producersBrokers with commission tracking
tasksWorkflow tasks
consentsKYC/compliance consent tracking

PHI Segregation

TablePurpose
private.client_health_profilesSegregated health information

MarketFinder (NEW in v2.2.1)

TablePurpose
marketfinder_clientsProspects from Chrome Extension
marketfinder_client_locationsProspect property locations
marketfinder_clients_notesProspect notes
marketfinder_clients_chatLLM chat history

Client Extensions (NEW in v2.2.1)

TablePurpose
client_locationsClient property locations
client_notesClient notes
clients_chatClient chat history

Enums

Line of Business (lob)

property, auto, liability, workers_comp, travel, life, health, marine, cyber, other

Claim Status (claim_status)

open, pending_info, under_review, approved, denied, litigated, closed

Claim Type (claim_type)

first_party, third_party, liability, workers_comp, health, property_auto, other

Cause of Loss (cause_of_loss)

fire, water, collision, theft, wind, liability, hail, flood, earthquake, hurricane, vandalism, cyber, other

Priority

low, normal, high

Payment Type (payment_type)

indemnity, expense

Payment Method (payment_method)

check, eft, ach, wire, card, other

Recovery Type (recovery_type)

subrogation, salvage, contribution, other

Policy Status (policy_status)

quote, bound, active, expired, cancelled, declined, pending, unpaid, completed

Endorsement Action (endorsement_action)

add, remove, modify, correct, cancel, reinstate

Billing Status (billing_status)

draft, invoiced, part_paid, paid, void, refunded, chargeback

Receivable Type (receivable_type)

premium, fee, tax, installment, endorsement_delta

Party Role (party_role)

insured, additional_insured, loss_payee, mortgagee, broker, producer, beneficiary, dependent, claimant, witness, attorney, vendor


Multi-Tenant Isolation

All tables enforce tenant_id at the database level. Row-level security (RLS) policies should be applied in production.

sql
-- Example RLS policy
ALTER TABLE clients ENABLE ROW LEVEL SECURITY;

CREATE POLICY tenant_isolation ON clients
  FOR ALL
  USING (tenant_id = current_setting('app.tenant_id'));

Migration Safety

The schema uses idempotent migrations:

  • CREATE TABLE IF NOT EXISTS - Creates tables only if missing
  • CREATE TYPE IF NOT EXISTS (wrapped in DO blocks) - Creates enums safely
  • CREATE INDEX IF NOT EXISTS - Creates indexes safely
  • DROP TRIGGER IF EXISTS before CREATE TRIGGER - Safe trigger updates

Safe to run multiple times - will NOT drop existing data.


Table Details

audit_logs

ColumnTypeNullableDefault
idBIGSERIALNO
tenant_idVARCHAR(26)NO
actionVARCHAR(50)NO
entity_typeVARCHAR(100)NO
entity_idUUIDYES
actor_idUUIDYES
actor_emailVARCHAR(255)YES
ip_addressINETYES
user_agentTEXTYES
request_methodVARCHAR(10)YES
request_pathTEXTYES
old_valuesJSONBYES
new_valuesJSONBYES
created_atTIMESTAMPTZNONOW()
correlation_idVARCHAR(50)YES

clients

ColumnTypeNullableDefault
idUUIDNOgen_random_uuid()
uuidUUIDNOgen_random_uuid()
tenant_idVARCHAR(26)NO
emailVARCHAR(255)YES
nameVARCHAR(255)NO
companyVARCHAR(255)YES
phoneVARCHAR(50)YES
addressTEXTYES
cityVARCHAR(100)YES
regionVARCHAR(100)YES
countryVARCHAR(100)YES
postal_codeVARCHAR(20)YES
external_refTEXTYES
date_of_birthDATEYES
tax_id_last4VARCHAR(4)YES
preferred_languageVARCHAR(10)YES
marketing_opt_inBOOLEANYESFALSE
kyc_levelVARCHAR(20)YES
createdTIMESTAMPTZNONOW()
modifiedTIMESTAMPTZNONOW()
client_typeVARCHAR(20)YES'individual'
websiteVARCHAR(255)YES
primary_contact_idUUIDYES
source_systemVARCHAR(50)YES

marketfinder_clients

ColumnTypeNullableDefault
idUUIDNOgen_random_uuid()
uuidUUIDNOgen_random_uuid()
tenant_idVARCHAR(26)NO
emailVARCHAR(255)YES
nameVARCHAR(255)NO
companyVARCHAR(255)YES
phoneVARCHAR(50)YES
addressTEXTYES
cityVARCHAR(100)YES
regionVARCHAR(100)YES
countryVARCHAR(100)YES'Canada'
postal_codeVARCHAR(20)YES
external_refTEXTYES
date_of_birthDATEYES
tax_id_last4VARCHAR(4)YES
preferred_languageVARCHAR(10)YES
marketing_opt_inBOOLEANYESFALSE
kyc_levelVARCHAR(20)YES
user_idVARCHAR(26)NO
webpage_urlVARCHAR(200)YES
naics_codeVARCHAR(10)YES
industryVARCHAR(255)YES
operationsTEXTYES
recommended_coveragesJSONBYES'[]'
classification_confidenceNUMERIC(3,2)YES
sourceVARCHAR(50)YES'chrome_extension'
statusVARCHAR(20)YES'draft'
converted_to_client_idUUIDYES
converted_atTIMESTAMPTZYES
is_activeBOOLEANNOTRUE
createdTIMESTAMPTZNONOW()
modifiedTIMESTAMPTZNONOW()
client_typeVARCHAR(20)YES'organization'
websiteVARCHAR(255)YES
primary_contact_idUUIDYES
source_systemVARCHAR(50)YES'chrome_extension'

Changelog

v2.2.1 (2025-11-25)

  • Added 7 new tables for MarketFinder Chrome Extension support
  • Added client_locations, client_notes, clients_chat tables
  • Added 68 Codex-recommended fields across 20 tables
  • Enhanced multi-currency support
  • Added external system integration fields

v2.2.0 (2025-11-08)

  • Initial production schema
  • 35 tables for comprehensive insurance operations
  • Multi-tenant isolation with tenant_id
  • PHI/PII segregation in private schema

Last Updated: 2025-11-25

Built with VitePress