# MDMS V2 Migration Guide

## Overview

This documentation outlines the process for replacing the `egov-mdms-service` with **MDMS V2**, which is database-driven and offers enhanced API capabilities for CRUD operations (Create, Read, Update, and Disable). By renaming the context path of MDMS V2 to `egov-mdms-service`, we ensure that core and other services can seamlessly interact with the new MDMS service without requiring changes.

## Key Changes

1. **MDMS V2**:
   * **Database-based**: Stores master data in a database rather than static files in a GitHub repository.
   * **CRUD APIs**: Allows users to dynamically interact with the master data through APIs for adding, updating, and disabling records.
   * **Backward Compatibility**: MDMS V2 retains compatibility with MDMS V1 search APIs, allowing services using `egov-mdms-service` to function without changes.
2. **egov-mdms-service**:
   * **File-based**: Managed master data as static JSON files stored in a GitHub repository.
   * **Limited Interaction**: Primarily served data without allowing user modification through APIs.

## Migration Steps

**1. Rename MDMS V2 Context Path**

Rename the context path of **MDMS V2** to `egov-mdms-service`in your environment. This ensures that all existing core and dependent services will seamlessly point to the new MDMS V2 without the need for any modifications.

* For example, if MDMS V2 is running on `/mdms-v2`, change it to `/egov-mdms-service` in the environment configurations.

**2. Remove Existing `egov-mdms-service`**

Delete the existing `egov-mdms-service` setup:

* **Pods**: Remove the running pods related to the old `egov-mdms-service`.
* **Service**: Delete the service definition.
* **Ingress**: Remove or update the ingress to redirect to the new MDMS V2.

**3. Deploy MDMS V2 with Configuration**

Deploy or redeploy **MDMS V2** with the updated context path (`/egov-mdms-service`) and database configurations enabled.

Ensure the following configurations are set:

* **Database connection** (for master data storage)
* **API configurations** (for CRUD operations)
* **Backwards compatibility enabled** (for V1 search APIs)

**4. Restart Zuul Gateway**

Once MDMS V2 is deployed and running, restart the **Zuul Gateway** (or any API gateway) to ensure that it picks up the new routing mappings to the renamed MDMS service (`egov-mdms-service`).

**5. Restart Dependent Services**

Restart all core and dependent services with configuration changes enabled so that they point to the newly deployed **MDMS V2**. This ensures that the services can now interact with the updated APIs provided by MDMS V2.

{% hint style="info" %}
**Note**: Some services, such as **ENC service** and **User service**, have direct dependencies on `egov-mdms-service` and specific data sets. Ensure that necessary data is added to the tenant(s) where this activity is being performed.
{% endhint %}

Use the below scripts to add default data for the roles and security policy so that user service will get started and we can proceed with adding more data.

{% tabs %}
{% tab title="Create Table Script" %}

```
-- Create the table if it doesn't already exist
CREATE TABLE IF NOT EXISTS public.eg_mdms_data
(
    id VARCHAR(64) NOT NULL,
    tenantid VARCHAR(255) NOT NULL,
    uniqueidentifier VARCHAR(255) NOT NULL,
    schemacode VARCHAR(255) NOT NULL,
    data JSONB NOT NULL,
    isactive BOOLEAN NOT NULL,
    createdby VARCHAR(64),
    lastmodifiedby VARCHAR(64),
    createdtime BIGINT,
    lastmodifiedtime BIGINT,
    CONSTRAINT pk_eg_mdms_data PRIMARY KEY (tenantid, schemacode, uniqueidentifier),
    CONSTRAINT uk_eg_mdms_data UNIQUE (id)
);
```

{% endtab %}

{% tab title="Insert Roles data" %}

```
-- Insert data into the table
INSERT INTO public.eg_mdms_data (
    id, tenantid, uniqueidentifier, schemacode, data, isactive, createdby, lastmodifiedby, createdtime, lastmodifiedtime
) VALUES 
(
    '503fc752-4702-4236-jaga-3f9fdc2e664e', 
    'mz', 
    'SUPERUSER', 
    'ACCESSCONTROL-ROLES.roles', 
    '{"code": "SUPERUSER", "name": "Super User", "description": "Super User. Can change all master data and has access to all the system screens."}', 
    true, 
    '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9', 
    '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9', 
    1700735390109, 
    1700735390109
),
(
    '503fc752-4702-4236-jaga-3f9fdc2e1234', 
    'mz', 
    'EMPLOYEE', 
    'ACCESSCONTROL-ROLES.roles', 
    '{"code": "EMPLOYEE", "name": "EMPLOYEE", "description": "EMPLOYEE Can change all master data and has access to all the system screens."}', 
    true, 
    '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9', 
    '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9', 
    1700735390109, 
    1700735390109
)
RETURNING tenantid, uniqueidentifier, schemacode;

```

{% endtab %}

{% tab title="Insert Security policy" %}

```sql
// Some code

-- Insert data into the table
INSERT INTO public.eg_mdms_data (
    id, tenantid, uniqueidentifier, schemacode, data, isactive, createdby, lastmodifiedby, createdtime, lastmodifiedtime
) VALUES 
(
    'b01cb9ee-1cf6-4b12-990d-a412750088cd', 
    'mz', 
    'ALL_ACCESS', 
    'DataSecurity.DecryptionABAC', 
    '{"key": "ALL_ACCESS", "roleAttributeAccessList": [{"roleCode": "CITIZEN", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/emailId"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/username"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/pan"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/aadhaarNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/permanentAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/correspondenceAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/addresses/*/address"}, "accessType": "PLAIN"}]}, {"roleCode": "ANONYMOUS", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/emailId"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/username"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/pan"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/aadhaarNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/permanentAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/correspondenceAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/addresses/*/address"}, "accessType": "PLAIN"}]}, {"roleCode": "EMPLOYEE", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/emailId"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/username"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/pan"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/aadhaarNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/permanentAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/correspondenceAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/addresses/*/address"}, "accessType": "PLAIN"}]}]}'::jsonb, 
    true, 
    '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9', 
    '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9', 
    1700804076399, 
    1700804076399
),
(
    '6e60a28e-bf58-445b-ac94-b293f5aa2a1a', 
    'mz', 
    'DescriptionReport', 
    'DataSecurity.DecryptionABAC', 
    '{"key": "DescriptionReport", "roleAttributeAccessList": [{"roleCode": "EMPLOYEE", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}]}]}'::jsonb, 
    true, 
    '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9', 
    '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9', 
    1700804101912, 
    1700804101912
),
('d227ee3f-342a-4d09-8d15-58414075d023', 'mz', 'UserListSelf', 'DataSecurity.DecryptionABAC', 
'{"key": "UserListSelf", "roleAttributeAccessList": [{"roleCode": "CITIZEN", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/emailId"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/username"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/pan"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/aadhaarNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/permanentAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/correspondenceAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/addresses/*/address"}, "accessType": "PLAIN"}]}, {"roleCode": "EMPLOYEE", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/emailId"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/username"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/pan"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/aadhaarNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/permanentAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/correspondenceAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/addresses/*/address"}, "accessType": "PLAIN"}]}]}', 
TRUE, '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9', '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9', '1700804205711', '1700804205711'),

('33478b40-b324-44a1-a221-795355541c23', 'mz', 'UserListOtherBulk', 'DataSecurity.DecryptionABAC', 
'{"key": "UserListOtherBulk", "roleAttributeAccessList": [{"roleCode": "EMPLOYEE", "attributeAccessList": [{"attribute": {"jsonPath": "*/emailId"}, "accessType": "NONE"}, {"attribute": {"jsonPath": "*/username"}, "accessType": "NONE"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "NONE"}, {"attribute": {"jsonPath": "*/pan"}, "accessType": "NONE"}, {"attribute": {"jsonPath": "*/aadhaarNumber"}, "accessType": "NONE"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "NONE"}, {"attribute": {"jsonPath": "*/permanentAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/correspondenceAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/addresses/*/address"}, "accessType": "PLAIN"}]}, {"roleCode": "SUPERUSER", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}]}, {"roleCode": "GRO", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber", "maskingTechnique": "mobile"}, "accessType": "MASK"}]}, {"roleCode": "DGRO", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber", "maskingTechnique": "mobile"}, "accessType": "MASK"}]}, {"roleCode": "CSR", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber", "maskingTechnique": "mobile"}, "accessType": "MASK"}]}, {"roleCode": "PGR-ADMIN", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber", "maskingTechnique": "mobile"}, "accessType": "MASK"}]}, {"roleCode": "TL_CEMP", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber", "maskingTechnique": "mobile"}, "accessType": "MASK"}]}, {"roleCode": "TL_APPROVER", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber", "maskingTechnique": "mobile"}, "accessType": "MASK"}]}, {"roleCode": "TL_DOC_VERIFIER", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber", "maskingTechnique": "mobile"}, "accessType": "MASK"}]}, {"roleCode": "TL_FIELD_INSPECTOR", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}]}, {"roleCode": "CEMP", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber", "maskingTechnique": "mobile"}, "accessType": "MASK"}]}, {"roleCode": "FEMP", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}]}, {"roleCode": "STADMIN", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber", "maskingTechnique": "mobile"}, "accessType": "MASK"}]}]}', 
TRUE, '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9', '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9', '1700804234349', '1700804234349'),
(
    '68b40c9c-cb52-4b61-a362-502763358622',
    'mz',
    'UserListOtherIndividual',
    'DataSecurity.DecryptionABAC',
    '{"key": "UserListOtherIndividual", "roleAttributeAccessList": [{"roleCode": "EMPLOYEE", "attributeAccessList": [{"attribute": {"jsonPath": "*/emailId"}, "accessType": "NONE"}, {"attribute": {"jsonPath": "*/username"}, "accessType": "NONE"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "NONE"}, {"attribute": {"jsonPath": "*/pan"}, "accessType": "NONE"}, {"attribute": {"jsonPath": "*/aadhaarNumber"}, "accessType": "NONE"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "NONE"}, {"attribute": {"jsonPath": "*/permanentAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/correspondenceAddress/address"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/addresses/*/address"}, "accessType": "PLAIN"}]}, {"roleCode": "SUPERUSER", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/emailId"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/username"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "PLAIN"}]}, {"roleCode": "GRO", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}]}, {"roleCode": "DGRO", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}]}, {"roleCode": "CSR", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}]}, {"roleCode": "PGR-ADMIN", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}]}, {"roleCode": "TL_CEMP", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/emailId"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/pan"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/aadhaarNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "PLAIN"}]}, {"roleCode": "TL_APPROVER", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/emailId"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/pan"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/aadhaarNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "PLAIN"}]}, {"roleCode": "TL_DOC_VERIFIER", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/emailId"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/pan"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/aadhaarNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "PLAIN"}]}, {"roleCode": "TL_FIELD_INSPECTOR", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/emailId"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/pan"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/aadhaarNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "PLAIN"}]}, {"roleCode": "CEMP", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/emailId"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/pan"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/aadhaarNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "PLAIN"}]}, {"roleCode": "FEMP", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/emailId"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/altContactNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/pan"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/aadhaarNumber"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/guardian"}, "accessType": "PLAIN"}]}, {"roleCode": "STADMIN", "attributeAccessList": [{"attribute": {"jsonPath": "*/name"}, "accessType": "PLAIN"}, {"attribute": {"jsonPath": "*/mobileNumber", "maskingTechnique": "mobile"}, "accessType": "MASK"}}]}]}',
    TRUE,
    '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9',
    '0da6b089-265e-44ef-bf7f-9e0d3ef47bf9',
    '1700804248221',
    '1700804248221'
)



RETURNING tenantid, uniqueidentifier, schemacode;

```

{% endtab %}

{% tab title="Other datas" %}

<pre><code>"id","tenantid","uniqueidentifier","schemacode","data","isactive","createdby","lastmodifiedby","createdtime","lastmodifiedtime"
<strong>
</strong><strong>"e4cf98ee-e908-48c3-bf8c-14fb09ef81de"	"mz"	"User"	"DataSecurity.EncryptionPolicy"	"{""key"": ""User"", ""attributeList"": [{""type"": ""Normal"", ""jsonPath"": ""name""}, {""type"": ""Normal"", ""jsonPath"": ""mobileNumber""}, {""type"": ""Normal"", ""jsonPath"": ""emailId""}, {""type"": ""Normal"", ""jsonPath"": ""username""}, {""type"": ""Normal"", ""jsonPath"": ""altContactNumber""}, {""type"": ""Normal"", ""jsonPath"": ""pan""}, {""type"": ""Normal"", ""jsonPath"": ""aadhaarNumber""}, {""type"": ""Normal"", ""jsonPath"": ""guardian""}, {""type"": ""Normal"", ""jsonPath"": ""permanentAddress/address""}, {""type"": ""Normal"", ""jsonPath"": ""correspondenceAddress/address""}, {""type"": ""Normal"", ""jsonPath"": ""addresses/*/address""}]}"	true	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	1700804635439	1700804635439
</strong>"98a0c1c1-25f3-4577-a668-9b8cc0753425"	"mz"	"UserSearchCriteria"	"DataSecurity.EncryptionPolicy"	"{""key"": ""UserSearchCriteria"", ""attributeList"": [{""type"": ""Normal"", ""jsonPath"": ""userName""}, {""type"": ""Normal"", ""jsonPath"": ""name""}, {""type"": ""Normal"", ""jsonPath"": ""mobileNumber""}, {""type"": ""Normal"", ""jsonPath"": ""aadhaarNumber""}, {""type"": ""Normal"", ""jsonPath"": ""pan""}, {""type"": ""Normal"", ""jsonPath"": ""emailId""}]}"	true	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	1700804645695	1700804645695
"03d3ab8a-6d44-4ba3-a507-3e2fa7c69bd6"	"mz"	"BndDetail"	"DataSecurity.EncryptionPolicy"	"{""key"": ""BndDetail"", ""attributeList"": [{""type"": ""Normal"", ""jsonPath"": ""mobileno""}, {""type"": ""Normal"", ""jsonPath"": ""emailid""}, {""type"": ""Normal"", ""jsonPath"": ""aadharno""}, {""type"": ""Normal"", ""jsonPath"": ""icdcode""}]}"	true	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	1700804699901	1700804699901
"a54e8214-300f-4cf2-9efa-aa207dd7b82c"	"mz"	"Property"	"DataSecurity.EncryptionPolicy"	"{""key"": ""Property"", ""attributeList"": [{""type"": ""Normal"", ""jsonPath"": ""address/street""}]}"	true	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	1700804713610	1700804713610
"6654445d-ba93-411b-9c84-927924264e8a"	"mz"	"001"	"DataSecurity.MaskingPatterns"	"{""pattern"": "".(?=.{4})"", ""patternId"": ""001""}"	true	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	1700804772944	1700804772944
"f33e86b3-e43f-4d21-b1d6-16d78cd1b22a"	"mz"	"002"	"DataSecurity.MaskingPatterns"	"{""pattern"": ""\\B[a-zA-Z0-9]"", ""patternId"": ""002""}"	true	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	1700804791784	1700804791784
"85c2f358-cc26-4adc-bb5a-735808296453"	"mz"	"003"	"DataSecurity.MaskingPatterns"	"{""pattern"": "".(?=.{2})"", ""patternId"": ""003""}"	true	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	1700804802503	1700804802503
"aec292f3-4194-413e-b13c-2de67cb64fa7"	"mz"	"004"	"DataSecurity.MaskingPatterns"	"{""pattern"": ""(?&#x3C;=.)[^@\\n](?=[^@\\n]*?@)|(?:(?&#x3C;=@.)|(?!^)\\G(?=[^@\\n]*$)).(?!$)"", ""patternId"": ""004""}"	true	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	1700804811911	1700804811911
"64bf6b50-c2ab-482f-a998-85c3eab25721"	"mz"	"005"	"DataSecurity.MaskingPatterns"	"{""pattern"": ""[A-Za-zÀ-ȕ0-9(),-_., ]"", ""patternId"": ""005""}"	true	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	1700804821219	1700804821219
"8a593b39-e894-4169-8555-d1bbe19d230c"	"mz"	"006"	"DataSecurity.MaskingPatterns"	"{""pattern"": ""\\w(?=(?:[ \\w]*\\w){2}$)"", ""patternId"": ""006""}"	true	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	1700804837750	1700804837750
"8d646350-8453-4de9-ac9b-1c57c96791f9"	"mz"	"007"	"DataSecurity.MaskingPatterns"	"{""pattern"": ""(?&#x3C;=.).(?=.{3})"", ""patternId"": ""007""}"	true	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	1700804848382	1700804848382
"b4cacb75-573f-4cec-9785-b35f7e8227a0"	"mz"	"008"	"DataSecurity.MaskingPatterns"	"{""pattern"": ""(?&#x3C;=.).(?=.{2})"", ""patternId"": ""008""}"	true	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	"0da6b089-265e-44ef-bf7f-9e0d3ef47bf9"	1700804861081	1700804861081
"13852799-4e94-432f-8373-4e0fcfcd0d74"	"mz"	"User"	"DataSecurity.SecurityPolicy"	"{""model"": ""User"", ""attributes"": [{""name"": ""name"", ""jsonPath"": ""name"", ""patternId"": ""002"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""mobileNumber"", ""jsonPath"": ""mobileNumber"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""emailId"", ""jsonPath"": ""emailId"", ""patternId"": ""004"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""username"", ""jsonPath"": ""username"", ""patternId"": ""002"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""altContactNumber"", ""jsonPath"": ""altContactNumber"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""alternatemobilenumber"", ""jsonPath"": ""alternatemobilenumber"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""pan"", ""jsonPath"": ""pan"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""aadhaarNumber"", ""jsonPath"": ""aadhaarNumber"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""guardian"", ""jsonPath"": ""guardian"", ""patternId"": ""002"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""permanentAddress"", ""jsonPath"": ""permanentAddress/address"", ""patternId"": ""003"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""correspondenceAddress"", ""jsonPath"": ""correspondenceAddress/address"", ""patternId"": ""003"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""fatherOrHusbandName"", ""jsonPath"": ""fatherOrHusbandName"", ""patternId"": ""002"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""searchUsername"", ""jsonPath"": ""userName"", ""patternId"": ""002"", ""defaultVisibility"": ""PLAIN""}], ""uniqueIdentifier"": {""name"": ""uuid"", ""jsonPath"": ""/uuid""}, ""roleBasedDecryptionPolicy"": [{""roles"": [""PGR_LME"", ""GRO""], ""attributeAccessList"": [{""attribute"": ""name"", ""firstLevelVisibility"": ""MASKED"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""mobileNumber"", ""firstLevelVisibility"": ""MASKED"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""username"", ""firstLevelVisibility"": ""MASKED"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""permanentAddress"", ""firstLevelVisibility"": ""MASKED"", ""secondLevelVisibility"": ""PLAIN""}]}, {""roles"": [""INTERNAL_MICROSERVICE_ROLE""], ""attributeAccessList"": [{""attribute"": ""mobileNumber"", ""firstLevelVisibility"": ""PLAIN"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""fatherOrHusbandName"", ""firstLevelVisibility"": ""PLAIN"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""correspondenceAddress"", ""firstLevelVisibility"": ""PLAIN"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""name"", ""firstLevelVisibility"": ""PLAIN"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""emailId"", ""firstLevelVisibility"": ""PLAIN"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""permanentAddress"", ""firstLevelVisibility"": ""PLAIN"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""username"", ""firstLevelVisibility"": ""PLAIN"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""altContactNumber"", ""firstLevelVisibility"": ""PLAIN"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""alternatemobilenumber"", ""firstLevelVisibility"": ""PLAIN"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""pan"", ""firstLevelVisibility"": ""PLAIN"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""aadhaarNumber"", ""firstLevelVisibility"": ""PLAIN"", ""secondLevelVisibility"": ""PLAIN""}, {""attribute"": ""guardian"", ""firstLevelVisibility"": ""PLAIN"", ""secondLevelVisibility"": ""PLAIN""}]}]}"	true	"7e97d4b7-8ec9-4b4e-b6cf-e76f7e4e050a"	"7e97d4b7-8ec9-4b4e-b6cf-e76f7e4e050a"	1701348865116	1701348865116
"a94be37f-236e-4183-a9fb-f88c968d3d92"	"mz"	"UserSelf"	"DataSecurity.SecurityPolicy"	"{""model"": ""UserSelf"", ""attributes"": [{""name"": ""name"", ""jsonPath"": ""name"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""mobileNumber"", ""jsonPath"": ""mobileNumber"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""emailId"", ""jsonPath"": ""emailId"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""username"", ""jsonPath"": ""username"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""altContactNumber"", ""jsonPath"": ""altContactNumber"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""alternatemobilenumber"", ""jsonPath"": ""alternatemobilenumber"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""pan"", ""jsonPath"": ""pan"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""aadhaarNumber"", ""jsonPath"": ""aadhaarNumber"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""guardian"", ""jsonPath"": ""guardian"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""permanentAddress"", ""jsonPath"": ""permanentAddress/address"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""correspondenceAddress"", ""jsonPath"": ""correspondenceAddress/address"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""fatherOrHusbandName"", ""jsonPath"": ""fatherOrHusbandName"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}], ""uniqueIdentifier"": {""name"": ""uuid"", ""jsonPath"": ""/uuid""}, ""roleBasedDecryptionPolicy"": []}"	true	"7e97d4b7-8ec9-4b4e-b6cf-e76f7e4e050a"	"7e97d4b7-8ec9-4b4e-b6cf-e76f7e4e050a"	1701348904508	1701348904508
"a41fc892-ae6e-44b7-9137-9aac576d8212"	"mz"	"IndividualEncrypt"	"DataSecurity.SecurityPolicy"	"{""model"": ""IndividualEncrypt"", ""attributes"": [{""name"": ""mobileNumber"", ""jsonPath"": ""mobileNumber"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""aadhaarNumber"", ""jsonPath"": ""identifiers/*/identifierId"", ""patternId"": ""001"", ""defaultVisibility"": ""MASKED""}], ""uniqueIdentifier"": {""name"": ""id"", ""jsonPath"": ""/id""}, ""roleBasedDecryptionPolicy"": [{""roles"": [""MUKTA_ADMIN""], ""attributeAccessList"": [{""attribute"": ""aadhaarNumber"", ""firstLevelVisibility"": ""PLAIN"", ""secondLevelVisibility"": ""PLAIN""}]}]}"	true	"7e97d4b7-8ec9-4b4e-b6cf-e76f7e4e050a"	"7e97d4b7-8ec9-4b4e-b6cf-e76f7e4e050a"	1701348925408	1701348925408
"39404214-a403-4e85-be6e-578443b8b652"	"mz"	"IndividualSearchEncrypt"	"DataSecurity.SecurityPolicy"	"{""model"": ""IndividualSearchEncrypt"", ""attributes"": [{""name"": ""mobileNumber"", ""jsonPath"": ""mobileNumber"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""aadhaarNumber"", ""jsonPath"": ""identifier/identifierId"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}], ""uniqueIdentifier"": {""name"": ""id"", ""jsonPath"": ""/id""}, ""roleBasedDecryptionPolicy"": []}"	true	"7e97d4b7-8ec9-4b4e-b6cf-e76f7e4e050a"	"7e97d4b7-8ec9-4b4e-b6cf-e76f7e4e050a"	1701348937235	1701348937235
"28aa0518-8428-409b-81fa-3a3c4c8b3978"	"mz"	"IndividualSearchIdentifierEncrypt"	"DataSecurity.SecurityPolicy"	"{""model"": ""IndividualSearchIdentifierEncrypt"", ""attributes"": [{""name"": ""aadhaarNumber"", ""jsonPath"": ""identifier/identifierId"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}], ""uniqueIdentifier"": {""name"": ""id"", ""jsonPath"": ""/id""}, ""roleBasedDecryptionPolicy"": []}"	true	"7e97d4b7-8ec9-4b4e-b6cf-e76f7e4e050a"	"7e97d4b7-8ec9-4b4e-b6cf-e76f7e4e050a"	1701348949320	1701348949320
"a9949e4b-1dc4-488e-821a-066b1f2b7097"	"mz"	"IndividualSearchMobileNumberEncrypt"	"DataSecurity.SecurityPolicy"	"{""model"": ""IndividualSearchMobileNumberEncrypt"", ""attributes"": [{""name"": ""mobileNumber"", ""jsonPath"": ""mobileNumber"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}], ""uniqueIdentifier"": {""name"": ""id"", ""jsonPath"": ""/id""}, ""roleBasedDecryptionPolicy"": []}"	true	"7e97d4b7-8ec9-4b4e-b6cf-e76f7e4e050a"	"7e97d4b7-8ec9-4b4e-b6cf-e76f7e4e050a"	1701348958311	1701348958311
"cb29a9ad-e41e-41b0-a731-fa68247e23b8"	"mz"	"IndividualDecrypt"	"DataSecurity.SecurityPolicy"	"{""model"": ""IndividualDecrypt"", ""attributes"": [{""name"": ""mobileNumber"", ""jsonPath"": ""mobileNumber"", ""patternId"": ""001"", ""defaultVisibility"": ""PLAIN""}, {""name"": ""aadhaarNumber"", ""jsonPath"": ""identifiers/*/identifierId"", ""patternId"": ""001"", ""defaultVisibility"": ""MASKED""}], ""uniqueIdentifier"": {""name"": ""id"", ""jsonPath"": ""/id""}, ""roleBasedDecryptionPolicy"": []}"	true	"f4044a41-40ea-41c8-b43a-2374d55e8f8e"	"aeb85b37-c996-4218-bdca-1b00cc268f2f"	1703135169818	1703841425128
</code></pre>

{% endtab %}
{% endtabs %}

## Data Migration Process

Data migration is a **separate** and essential activity that must be handled **master by master**. The migration process includes:

1. **Schema Creation**:
   * For each master, ensure that the necessary schema is created in the database.
   * Verify that the structure aligns with the expected format in MDMS V2.
2. **Data Migration**:
   * Migrate data master by master into the corresponding database tables.
   * Ensure that the migrated data is valid and adheres to the schema.
   * Refer to [this document](https://core.digit.org/platform/core-services/mdms-v2-master-data-management-service/mdms-migration) to learn more about data migration.

I have attached the default MDMS data and schema that were created in UAT. This can be used to load the default MDMS for the HCM Product & Console. It can be imported into any environment, and you can change the tenant from 'mz' by using the 'find and replace' function. After that, delete any unnecessary masters and add new ones according to your use case.

{% file src="/files/UrivyBICcqh7ou7nM3Hj" %}
uat mdms data backup
{% endfile %}

## Additional Notes

* **Backward Compatibility**: Since MDMS V2 supports the V1 search APIs, all core and dependent services will continue to function normally without modification.
* **Database Configuration**: Ensure that database replication and backups are in place, especially during the migration, to prevent data loss.
* **Service Downtime**: Depending on your infrastructure, plan for potential service downtime while removing the old `egov-mdms-service` and deploying MDMS V2.
* The migration to **MDMS V2** is **successfully completed** in the **Unified UAT** environment.
* **All MDMS data** for -

  * **HCM** (including HCM Prod and HCM Console)
  * **Sanitation**
  * **Core Master Data**

  is migrated.

### **Database Dump & Schema Information**

A database dump containing all the necessary schemas and data will be provided. This includes:

* **Core-related** master data.
* **Health** and **Console-related** masters.

You can filter the **Core-related data** from the dump and update your database accordingly for future environments.

## Conclusion

By following this migration guide, you can seamlessly transition from `egov-mdms-service` to the more dynamic and API-driven **MDMS V2**. The new system enhances user interaction while maintaining compatibility with existing services, ensuring a smooth integration into the ecosystem.


---

# 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://workbench.digit.org/setup/configurations/mdms-v2-migration-guide.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.
