# Update Persister Configuration

## Overview

Update persister configuration -

* If you **add, remove, or rename** a field in the CMS request payload (service or address).
* If you want new data to be saved to the database.

#### When is it required?

* Field added/removed/renamed in the request payload (e.g., `service`, `address`).
* New data needs to be persisted to the DB (e.g., a new column added).
* The database schema is modified (e.g., table changes, new columns).
* New nested objects/entities are introduced in the payload.
* Audit logs or Elasticsearch indexing is added via Persister.

#### ⚠️ What if not updated?

* Data won’t be saved.
* DB errors may occur.
* UI or search APIs may break due to missing data.

> <mark style="color:$info;background-color:$info;">💡 Always ensure JSONPaths in</mark> <mark style="color:$info;background-color:$info;"></mark><mark style="color:$info;background-color:$info;">`persister.yaml`</mark> <mark style="color:$info;background-color:$info;"></mark><mark style="color:$info;background-color:$info;">match your latest payload and DB structure.</mark>

**Configuration File**&#x20;

* File: `egov-persister/pgr-services-persister.yml`
* This file maps fields from Kafka topics (like `save-pgr-request`) to DB tables (like `eg_pgr_service_v2`).

## Steps

{% stepper %}
{% step %}

### Create/Insert New/Changed Fields

* Find the section: `fromTopic: save-pgr-request`
* In the relevant `INSERT` query (e.g., for `eg_pgr_service_v2`):
  * Add your new column to the SQL (e.g., `priority=?`)
  * Add a `jsonPath` mapping to the new field (e.g., `- jsonPath: $.service.priority`)
* **Example:**

  ```
  - query: INSERT INTO eg_pgr_service_v2(..., priority) VALUES (..., ?);
    ...
    jsonMaps:
      ...
      - jsonPath: $.service.priority
  ```

{% endstep %}

{% step %}

### Update New/Changed Fields

* Find the section: `fromTopic: update-pgr-request`
* In the `UPDATE` query (for either service or address):
  * Add your new column (e.g., `priority=?`)
  * Add a `jsonPath` for the field (e.g., `- jsonPath: $.service.priority`)

{% hint style="info" %}
**Tip**: If the field is in an address, use the right table and path (e.g., `$.service.address.priority`).<br>
{% endhint %}
{% endstep %}

{% step %}

### Restart the Persister Service

* After saving and committing the YAML, restart the `egov-persister` service.
* **Why?** The service only reads the YAML at startup!
* **Kubernetes command:**

  ```
  kubectl rollout restart deployment egov-persister
  ```

{% endstep %}
{% endstepper %}

## Summary - Checklist

<table><thead><tr><th width="270.9375">Step</th><th width="291.48828125">What To Do</th><th>Why</th></tr></thead><tbody><tr><td>1️⃣ Update save-pgr-request</td><td>Map new fields for INSERT</td><td>For DB inserts</td></tr><tr><td>2️⃣ Update update-pgr-request</td><td>Map new fields for UPDATE</td><td>For DB updates</td></tr><tr><td>3️⃣ Restart persister</td><td>Reload updated YAML config</td><td>To apply changes</td></tr></tbody></table>


---

# Agent Instructions: 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:

```
GET https://docs.digit.org/complaints-management/complaints-resolution-v2.10/deploy/customise/backend/update-persister-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
