This is the complete catalog of every table, index, constraint, and relationship in the EnrichNode database.
Core Pipeline Tables
companies
Primary enriched data store.
Column
Type
Constraints
id
SERIAL
PRIMARY KEY
orgNr
TEXT
UNIQUE NOT NULL
name
TEXT
address
TEXT
sni
TEXT[]
enriched_data
JSONB
Stores full EnrichmentResult including contacts (PII)
processed_at
TIMESTAMPTZ
source
TEXT
DEFAULT ‘pipeline’
domain
TEXT
(added migration 002)
lead_score
NUMERIC
(added migration 002)
contacts_count
INTEGER
(added migration 002)
has_vd_contact
BOOLEAN
(added migration 002)
last_enriched_at
TIMESTAMPTZ
(added migration 002)
enrichment_tier
TEXT
CHECK: active/stable/dormant (migration 003)
next_enrichment_after
TIMESTAMPTZ
(migration 003)
data_fingerprint
TEXT
(migration 003)
enrichment_run_id
TEXT
(migration 003)
tier_assigned_at
TIMESTAMPTZ
(migration 003)
turnover_sek
BIGINT
(migration 005)
employee_count
INTEGER
(migration 005)
equity_sek
BIGINT
(migration 005)
bv_financial_year
INTEGER
(migration 005)
bv_financial_fetched_at
TIMESTAMPTZ
(migration 005)
embedding
VECTOR(1536)
(migration 007)
Indexes:
idx_companies_enriched_gin — GIN on enriched_data
idx_companies_needs_refresh — B-tree on processed_at NULLS FIRST
idx_companies_lead_score — B-tree on lead_score DESC NULLS LAST
idx_companies_has_vd — B-tree on has_vd_contact
idx_companies_domain — B-tree on domain
idx_companies_last_enriched — B-tree on last_enriched_at DESC NULLS LAST
idx_companies_tier — B-tree on (enrichment_tier, next_enrichment_after NULLS FIRST)
idx_companies_next_enrich — B-tree on next_enrichment_after NULLS FIRST WHERE NOT NULL
idx_companies_fingerprint — B-tree on data_fingerprint
idx_companies_embedding — IVFFlat on embedding vector_cosine_ops (lists=100)
leads
Sales-ready leads with validation layers.
Column
Type
Constraints
id
UUID
PRIMARY KEY
org_nr
TEXT
UNIQUE
name
TEXT
legal_form
TEXT
address
TEXT
sni_code
TEXT
sni_secondary
TEXT[]
business_desc
TEXT
employees
INTEGER
turnover
BIGINT
is_active
BOOLEAN
is_validated
BOOLEAN
confidence_score
NUMERIC(3,2)
validated_at
TIMESTAMPTZ
layer_registry
BOOLEAN
layer_website
BOOLEAN
layer_profiles
BOOLEAN
layer_news
BOOLEAN
website
TEXT
linkedin_url
TEXT
email
TEXT
phone
TEXT
source
TEXT
imported_at
TIMESTAMPTZ
updated_at
TIMESTAMPTZ
Bulk Import Tables
bolagsverket_companies
~2.9M records (651K active AB post-archive).
Column
Type
id
SERIAL PK
org_nr
TEXT UNIQUE
name
TEXT
legal_form
TEXT
registration_date
DATE
deregistration_date
DATE
deregistration_reason
TEXT
business_description
TEXT
address
TEXT
postal_code
TEXT
postal_city
TEXT
country
TEXT
is_active
BOOLEAN DEFAULT true
data_source
TEXT
imported_at
TIMESTAMPTZ
updated_at
TIMESTAMPTZ
scb_foundations
~1.8M records (post-archive: only AB).
Column
Type
id
SERIAL PK
org_nr
TEXT UNIQUE
name
TEXT
address
TEXT
postal_code
TEXT
postal_city
TEXT
co_address
TEXT
legal_form
INTEGER
status
INTEGER
entity_status
INTEGER
registration_date
DATE
sni_codes
TEXT[]
sni_primary
TEXT
advertising_block
BOOLEAN
data_source
TEXT
imported_at
TIMESTAMPTZ
updated_at
TIMESTAMPTZ
Compliance Tables
OptOut_Hashes
SHA-256 hashed contacts for opt-out.
CREATE TABLE "OptOut_Hashes" ( hashed_contact TEXT PRIMARY KEY);
RoPA_Log
Immutable audit trail (Article 30).
CREATE TABLE "RoPA_Log" ( id SERIAL PRIMARY KEY, timestamp TIMESTAMPTZ DEFAULT NOW(), "tableName" TEXT NOT NULL, operation TEXT NOT NULL, "recordId" TEXT, description TEXT);
Migration 002 adds:month_bucket column for efficient querying.
Article14_Notifications
GDPR Art. 14 notification log.
CREATE TABLE "Article14_Notifications" ( id SERIAL PRIMARY KEY, email TEXT NOT NULL, company_org_nr TEXT, sent_at TIMESTAMPTZ DEFAULT NOW(), method TEXT DEFAULT 'email', status TEXT DEFAULT 'sent', -- sent | failed | skipped error_message TEXT, UNIQUE (email, company_org_nr));
Quality & Error Tracking
enrichment_errors
Column
Type
id
SERIAL PK
org_nr
TEXT
timestamp
TIMESTAMPTZ
error_type
TEXT
error_message
TEXT
stack_trace
TEXT
retry_count
INTEGER
resolved
BOOLEAN
metadata
JSONB
enrichment_issues
Column
Type
Constraints
id
SERIAL PK
org_nr
TEXT
issue_type
TEXT
severity
TEXT
CHECK: low/medium/high/critical
description
TEXT
detected_at
TIMESTAMPTZ
status
TEXT
CHECK: open/in_progress/resolved/flagged_manual
resolution
TEXT
resolved_at
TIMESTAMPTZ
auto_remediation_attempts
INTEGER
last_auto_attempt_at
TIMESTAMPTZ
remediation_actions
Column
Type
id
SERIAL PK
org_nr
TEXT
action_type
TEXT
issue_id
INTEGER FK → enrichment_issues (ON DELETE SET NULL)