> For the complete documentation index, see [llms.txt](https://host2host.onibonje.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://host2host.onibonje.com/docs/30-database-schema-reference.md).

# Database Schema Reference

## 1. Overview

Consolidated **logical data model** for the H2H platform. Physical DDL via Flyway in `h2h-config-store`. **Database-agnostic** — same logical schema on PostgreSQL, Oracle, or SQL Server via [45 Database-Agnostic Persistence](/docs/45-database-agnostic-persistence.md) and [Persistence SPI](/docs/14-extensibility-framework.md) §6.

**Schemas:**

| Schema       | Purpose                                    |
| ------------ | ------------------------------------------ |
| `h2h_config` | Partner, integration, customization config |
| `h2h_tx`     | Transaction and file operational data      |
| `h2h_ext`    | Extension tables (`ext_*`)                 |
| `h2h_audit`  | Append-only audit (optional separate DB)   |

***

## 2. Entity Relationship (High Level)

```mermaid
erDiagram
  partner ||--o{ channel_config : has
  partner ||--o{ integration_profile : has
  integration_profile ||--|| route_template : uses
  route_template ||--o{ route_step : contains
  integration_profile ||--o| transform_spec : inbound
  integration_profile ||--o| ack_template : ack
  partner ||--o{ customization_profile : customizes
  partner ||--o{ file_registry : files
  payment_batch ||--o{ payment_instruction : lines
  payment_batch ||--o| file_registry : source
  partner ||--o{ event_subscription : subscribes
```

***

## 3. Configuration Domain (`h2h_config`)

### 3.1 Core Partner

| Table                    | Key columns                                                                                  |
| ------------------------ | -------------------------------------------------------------------------------------------- |
| `partner`                | partner\_id, name, country\_code, status, tier, environment                                  |
| `channel_config`         | partner\_id, channel\_type, protocol, connection\_params (JSON), poll\_cron                  |
| `websocket_subscription` | subscription\_id, partner\_id, channel\_id, event\_code, filter\_expression, message\_format |
| `credential_ref`         | partner\_id, ref\_type, vault\_path                                                          |
| `message_type`           | code, description, category                                                                  |

### 3.2 Integration

| Table                 | Key columns                                                                                                                                       |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `integration_profile` | profile\_id, partner\_id, message\_type, route\_template\_id, transform\_inbound\_id, validation\_ruleset\_id, ack\_template\_id, status, version |
| `route_template`      | template\_id, template\_code, version                                                                                                             |
| `route_step`          | template\_id, step\_order, step\_code, step\_config (JSON), on\_error                                                                             |
| `transform_spec`      | spec\_id, engine, source\_format, target\_format, spec\_body, sample\_input                                                                       |
| `validation_rule`     | ruleset\_id, priority, field\_path, operator, value, error\_code                                                                                  |
| `routing_rule`        | ruleset\_id, priority, condition, action, action\_params                                                                                          |
| `ack_template`        | template\_id, format, filename\_pattern, transform\_spec\_id                                                                                      |
| `cutoff_schedule`     | partner\_id, product\_code, schedule\_expression, timezone, holiday\_calendar\_id                                                                 |
| `holiday_calendar`    | calendar\_id, country\_code, holidays (JSON)                                                                                                      |

### 3.3 Versioning & Audit

| Table               | Key columns                                                                                                                    |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `config_version`    | entity\_type, entity\_id, version, status, published\_at                                                                       |
| `config_audit`      | audit\_id, entity\_type, action, previous\_snapshot, new\_snapshot, performed\_by, approval\_ref                               |
| `approval_policy`   | policy\_code, entity\_type, scope\_type, scope\_id, condition, priority                                                        |
| `approval_step_def` | policy\_id, step\_order, approver\_type, approver\_ref, quorum\_type, quorum\_count, sla\_hours                                |
| `approval_request`  | request\_id, policy\_id, entity\_type, entity\_id, submitted\_by, status, current\_step\_order, camunda\_process\_instance\_id |
| `approval_action`   | request\_id, step\_order, action, performed\_by, comment                                                                       |

### 3.4 Customization

| Table                    | Key columns                                                                                                                                                          |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `customization_profile`  | profile\_id, scope\_type, scope\_id, environment, version, security\_config, file\_mgmt\_config, observability\_config, camel\_config, finacle\_config (JSON blocks) |
| `custom_attribute_def`   | attr\_code, scope\_type, data\_type, validation\_regex                                                                                                               |
| `custom_attribute_value` | attr\_code, scope\_id, value\_text, value\_json                                                                                                                      |
| `extension_entity_def`   | entity\_code, json\_schema                                                                                                                                           |
| `extension_entity_row`   | entity\_code, scope\_id, row\_data (JSON)                                                                                                                            |

### 3.5 Extensibility

| Table                            | Key columns                                                                                                                                |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `script_def`                     | script\_id, language, script\_body, timeout\_ms, sandbox\_profile                                                                          |
| `hook_def`                       | hook\_point, script\_id, scope, priority                                                                                                   |
| `job_def`                        | job\_id, job\_type, schedule\_expression, schedule\_type, delay\_backbone, payload (JSON), enabled                                         |
| `job_schedule_state`             | job\_id, schedule\_version, next\_execute\_at, pending\_message\_ref, last\_executed\_at                                                   |
| `job_execution_log`              | execution\_id, job\_id, status, started\_at, finished\_at                                                                                  |
| `sql_task_def`                   | task\_code, parameter\_schema, dialect\_overrides                                                                                          |
| `event_subscription`             | subscription\_id, event\_code, handler\_type, handler\_ref, filter\_expression, consumer\_group                                            |
| `webhook_subscription`           | event\_code, target\_url, auth\_ref, filter\_expression                                                                                    |
| `event_def`                      | event\_code, category, payload\_schema, ordering\_required, system\_event                                                                  |
| `event_channel_def`              | channel\_id, event\_code, scope\_type, scope\_id, broker, destination\_name, partition\_strategy, partition\_key\_fields, partition\_count |
| `notification_provider_def`      | provider\_code, channel\_type, vendor, scope\_type, connection\_params, credential\_ref, rate\_limit\_per\_min                             |
| `notification_template`          | template\_code, channel\_type, locale, subject\_template, body\_template, version, status                                                  |
| `notification_subscription`      | event\_code, channel\_type, template\_code, provider\_id, recipient\_type, recipient\_ref, filter\_expression                              |
| `notification_delivery_log`      | delivery\_id, channel\_type, provider\_code, recipient, status, vendor\_message\_id, correlation\_id                                       |
| `notification_opt_out`           | recipient\_hash, channel\_type, opted\_out\_at                                                                                             |
| `finacle_operation_mapping`      | country\_code, canonical\_op, fcj\_op, fcubs\_service                                                                                      |
| `core_banking_provider_def`      | provider\_code, adapter\_bean, scope\_type, scope\_id, connection\_params, credential\_ref, priority                                       |
| `core_banking_operation_mapping` | provider\_code, canonical\_op, provider\_op, dialect\_overrides                                                                            |

***

## 4. Transaction Domain (`h2h_tx`)

| Table                   | Key columns                                                                                                                    |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `file_registry`         | file\_id, correlation\_id, partner\_id, direction, storage\_path, checksum\_sha256, status, delivery\_attempts                 |
| `file_delivery_receipt` | file\_id, delivered\_at, delivery\_method, remote\_checksum                                                                    |
| `payment_batch`         | batch\_id, correlation\_id, partner\_id, status, total\_count, total\_amount, value\_date                                      |
| `payment_instruction`   | instruction\_id, batch\_id, debit\_account, credit\_account, amount, customer\_reference, status, error\_code, bank\_reference |
| `idempotency_key`       | key\_hash, partner\_id, correlation\_id, created\_at, expires\_at                                                              |
| `transaction_index`     | correlation\_id, partner\_id, batch\_id, status, created\_at (search)                                                          |
| `event_handler_log`     | event\_id, subscription\_id, status, processed\_at                                                                             |
| `recon_item`            | item\_id, partner\_id, amount, reference, status, matched\_item\_id                                                            |
| `recon_match`           | match\_id, item\_ids, match\_type, matched\_at                                                                                 |

***

## 5. Indexes (Critical)

| Table                   | Index                                              |
| ----------------------- | -------------------------------------------------- |
| `integration_profile`   | (partner\_id, message\_type, environment, status)  |
| `customization_profile` | (scope\_type, scope\_id, environment, status)      |
| `file_registry`         | (partner\_id, status, created\_at)                 |
| `payment_batch`         | (correlation\_id), (partner\_id, created\_at)      |
| `payment_instruction`   | (batch\_id), (bank\_reference)                     |
| `idempotency_key`       | (key\_hash) UNIQUE                                 |
| `transaction_index`     | (correlation\_id), (partner\_id, created\_at DESC) |

***

## 6. Flyway Layout

```
db/migration/
├── common/
│   V1__partner_and_channel.sql
│   V2__integration_profile.sql
│   V3__transform_and_rules.sql
│   V4__customization.sql
│   V5__extensibility.sql          # job_def, job_schedule_state, script_def, hook_def
│   V6__transaction_tables.sql
│   V7__reconciliation.sql
│   V8__events.sql                 # event_def, event_channel_def, subscriptions
├── postgresql/
│   V1.1__jsonb_indexes.sql
├── oracle/
│   V1.1__json_indexes.sql
└── sqlserver/
    V1.1__json_check.sql
```

***

## 7. Retention

| Table               | Retention             |
| ------------------- | --------------------- |
| `idempotency_key`   | 30–90 days            |
| `payment_*`         | 7+ years              |
| `file_registry`     | Per partner agreement |
| `config_audit`      | 7+ years              |
| `job_execution_log` | 1 year                |
| `event_handler_log` | 1 year                |

***

## 8. Related Documents

* [04 Database-Driven Configuration](/docs/04-database-driven-configuration.md)
* [14 Extensibility Framework](/docs/14-extensibility-framework.md)
* [15 File Management System](/docs/15-file-management-system.md)
* [29 Canonical Data Model](/docs/29-canonical-data-model.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://host2host.onibonje.com/docs/30-database-schema-reference.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
