Skip to main content

Overview

PensionsPortal.ie uses PostgreSQL (hosted on Neon serverless) with Drizzle ORM for all data access. This document is the authoritative reference for the database schema, entity relationships, data classifications, and retention policies.

Entity Relationship Summary


Table Descriptions

users

Stores all authenticated principals. The brokerId column is the tenant anchor for broker-level users.

password_reset_tokens

Stores hashed password reset tokens for the forgot-password flow. Tokens are SHA-256 hashed before storage — plaintext is never persisted.

employers

The primary tenant-scoped entity. Every employer belongs to exactly one broker tenant.

providers

Pension product providers (insurers, fund managers). Not tenant-scoped — shared reference data.

schemes

A pension scheme belongs to one employer and uses one provider. The status column implements a finite state machine.

members

Individual scheme members. PPS numbers are stored encrypted (AES-256-GCM). Status implements a FSM.

keyFunctionHolders

Records the IORP II Key Function Holders (KFHs) appointed to a scheme. Pensions Authority notification status is tracked.

writtenPolicies

Tracks the 11 written policies required by IORP II. Each policy record stores its review status and RAG rating.
Policy types (policyTypeEnum):

oraReports

Own Risk Assessment (ORA) reports. Each ORA covers 7 risk categories, each with likelihood, impact, rating, and mitigation fields.
The 7 ORA risk categories are: investment, operational, compliance, governance, counterparty, liquidity, ESG.

healthCheckAssessments

Scheme health check assessments with 7 RAG ratings and an AI-generated executive summary.

acsWizard

Annual Compliance Statement (ACS) wizard completion tracking. IORP II requires trustees to submit an ACS annually. Dual trustee sign-off fields enforce the two-signatory requirement.

auditLogs

Append-only audit trail. No application-layer DELETE or UPDATE operations. Required for IORP II regulatory examination.
actorId is stored as plain text rather than a foreign key. This ensures audit records survive user deletion — a regulatory requirement.

ragCorpus

Regulatory document chunks for pgvector RAG. Contains only public regulatory text — no member or scheme data.

Data Classification Table


FSM Status Enums

Scheme Status FSM

Member Status FSM


Data Retention

Soft deletes (via status enums) are used throughout the application. Hard deletion of member records is only permitted after the 7-year retention period expires. A scheduled job (future work) will flag eligible records for review.

Migration Files

Database migrations are managed by Drizzle Kit. Migration files are located in drizzle/migrations/.

Running Migrations

Never run drizzle-kit push against the production database. Always use drizzle-kit migrate with reviewed migration files. The push command bypasses the migration history and can cause schema drift.