diff --git a/.github/keys/mosipgpgkey_pub.gpg b/.github/keys/mosipgpgkey_pub.gpg new file mode 100644 index 00000000..86e5dfe3 --- /dev/null +++ b/.github/keys/mosipgpgkey_pub.gpg @@ -0,0 +1,30 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQENBF4Voj4BCADMadISO9yCDWMqaIvLSpLbazvjz7Y5Sqdzn7dW0dt1LLbxlnGw +PAq4THeI5/6plotK1sOMVFh7iy57kwYUgzKnWnW5hNDPtaTCWDmrOftiHm0Q/fj2 +Zsy3aX0XuySQz7oycTnQ52p3zqGDlnH7zgPQV9dCCAIQMFbJZkoNpZxMRMN2Lnph +112Oi7ujO5/gIcrxLBQXe9zHVU9DT1C1JjY4eTajU9vg+muslwhoT633vYvuhj1q +UBnn6ZLUitw+Z8d6S9B8SEqcbd5O3ODGKhToDK9tC8rZCDFgmgcZYAZnuaJ2/bQB +uePiCKf4jkGpdtpAB4HIr2lGvK2rWbW0l2KpABEBAAG0SG1vc2lwIChUaGlzIGlz +IG1vc2lwIG1hdmVuIGNlbnRyYWwgcmVwbykgPG1vc2lwLmVtYWlsbm90aWZpZXJA +Z21haWwuY29tPokBPwQTAQIAKQUCXhWiPgIbAwUJA8JnAAcLCQgHAwIBBhUIAgkK +CwQWAgMBAh4BAheAAAoJEE7nVSof0F5k2EAIAKdflLyH8H93IFYOWZQtte07Ctu5 +SgWbgBpBKUYquTFphDOhplMB5/cik5eY3nSwuhWa1u6bwq/R6GvlnsH5JUkmIM8o +EHCx4GqR5Zq8LoZazqrVycWBkZp7IjKA2kc1MyhLUTLmdPu9/moi78ZRABvSW624 +NViSxyoypAMl4hHj4qlL2IEDEyv2/OwKz+Tt7zyk6/mFzpte3MzasSdLDdt5zhIG +s+QofZI7IqQ1C/GSa3R13sliXd+9F/7+edyK10sigRCL5SsmM3Yz/QifeE5+Rd5K +9vx5NTLvCPoNddFhFpXpeD8N3JLdh88mg+AROsI1tJPAuxx/JaS335M5+9m5AQ0E +XhWiPgEIAKuUHcEfHTKInylOj93JeCStbBUC2aeajNZTASGdv62TlFTJsgtyHC7+ +b6UYXvdwBB+JbCa1Nv53uVpvl2nrA1KmEm2wwCEh3wQ3Q8k2KDQ2Jm0APpTNCdVy +cPjN1pDwgqwYDkCv8B9ZdC9CuFY/hvU4KOkgk+OYyiQNC2IwKt0tKoGM4eUb7eVt +lFQ9t+Q0araXzefTTYzcP2kSLd6ZIPNyhJTSRiRWRbXLyTRvMQAkl4kF9sp3K3qt +uB5Q9GGpP7NJmF4LB1AxKjYDf12nFT9fqfjzIqW8i3gBc6WgI1bW7V5VTw7rrqCr +AUrJCf3HJv67PJ07gJYvNqstCiZtvBkAEQEAAYkBJQQYAQIADwUCXhWiPgIbDAUJ +A8JnAAAKCRBO51UqH9BeZBFDB/9wZy0IsdD/byau5SjpsVNPDoS7Cu7Ojfd4jFDe +I7ze78DIgXWsIrbWRu18UdbXhFUNJZOEK3lyQOvxpN2cGjSyAHVe2Gir7g/5+qkM +M+28wpGU+OL7ejAfup8vHmAUh6otkthHPGuQ7N2oYk9JVKvm6OjPsWdMb54iJS2x +XQ8FTs3ooRS6/biukRrgoYmX62oDJD4CcCh3UvMUslXtC7L/FX+4hmPx/wWa+iOO +utA+zLgOcjS15SB+pH47JHwHB7NJWr/+nxmkbCU6tOMdyznSCTiYMoF3AKeuxcAs +pD454Eioeq+WZ6CyY6Y278Q/iSnVNP6T1La6CdONdaOBRpdA +=e6L0 +-----END PGP PUBLIC KEY BLOCK----- diff --git a/.github/keys/mosipgpgkey_sec.gpg b/.github/keys/mosipgpgkey_sec.gpg new file mode 100644 index 00000000..b0180d54 --- /dev/null +++ b/.github/keys/mosipgpgkey_sec.gpg @@ -0,0 +1,59 @@ +-----BEGIN PGP PRIVATE KEY BLOCK----- + +lQPGBF4Voj4BCADMadISO9yCDWMqaIvLSpLbazvjz7Y5Sqdzn7dW0dt1LLbxlnGw +PAq4THeI5/6plotK1sOMVFh7iy57kwYUgzKnWnW5hNDPtaTCWDmrOftiHm0Q/fj2 +Zsy3aX0XuySQz7oycTnQ52p3zqGDlnH7zgPQV9dCCAIQMFbJZkoNpZxMRMN2Lnph +112Oi7ujO5/gIcrxLBQXe9zHVU9DT1C1JjY4eTajU9vg+muslwhoT633vYvuhj1q +UBnn6ZLUitw+Z8d6S9B8SEqcbd5O3ODGKhToDK9tC8rZCDFgmgcZYAZnuaJ2/bQB +uePiCKf4jkGpdtpAB4HIr2lGvK2rWbW0l2KpABEBAAH+BwMCQtDwzCTcteP/Cbg9 +9DugKCnTbSsnUwAuA+oWUdkVCkrL6pvFIPXkgpCq7Af2E3JLgYnKK6AVsbDkHPS2 ++UeZRgfnoYZJBH59pHbjwQuz7nKF10BikDIQwc5+fNuIg+GgD3bfsRrRwQMkrl5/ +T3KVnw8I6TinGGsdA+UpODf61UQNYajuAq3P3GswpvbpYHLadHz5hmRjYzTRUnfX +jn26DhxRH6m6ulp630QHTvDCzI6TrlvgI4ZGaowBCGbBuDb+gUL3HaBtm8ZDokRH +pa5FtI1kpujigZuZ0AvmeFXOwZsAsPsC1msmnq5PlOULovuY9/8tEgPBjV1jee7u +9ZOnsdmO06SQ2o7FLL7sVZW8xK0WeRZMHiv/sm+yYI5q+EFJXYBpHMUO3Q+xwNk6 +64Uj1PnYLjTM0VRrt144LOpyGCuBBmeGqCVp1HTHshK2qSv+hZXFYowl0ia7BQpm +Lh2dkUQs2pa5WmD8XHJnPdXN5FOXJvnLNHgreAwklXk2+TDXT00Vb5dYfvZ1p2Cp +IWmx6gV8qUy9EQIHp0vTLJPbF1t2YQGvUrHdcDrHPW83gF6ydMmdtfSASfP47ZU9 +Xkyqj7WdyZz+q0heW1R5MUxrYYK0hkSN1wiB/SR+giOuEwJ8qX95cs1PuJXmYZrp +zwrR2oKMrzWR78zi2rDHoTQUEj/y4RU/wOQReMUHHljFv8ROfLGMs/zJUVKkq7uB +DODWFM1XA/uhpI8rwIyox3tiBf4v2PFzwotUAiOrpHej8LochTMoTxL4nglsAEbw +K9e0gzAzYyiR1EHBdIIsAY2pwkxZz52aFqL0KwxKtBFYWx/VApm+FcT0OQsJO3VU +YFR11x5pAf1cmfq36SoCiq5HQnyHRYNzJ9k2b1P6QK6as4+ZWSw3f/Mmfcbe4Swt +I+hFG77L8oOltEhtb3NpcCAoVGhpcyBpcyBtb3NpcCBtYXZlbiBjZW50cmFsIHJl +cG8pIDxtb3NpcC5lbWFpbG5vdGlmaWVyQGdtYWlsLmNvbT6JAT8EEwECACkFAl4V +oj4CGwMFCQPCZwAHCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgAAKCRBO51UqH9Be +ZNhACACnX5S8h/B/dyBWDlmULbXtOwrbuUoFm4AaQSlGKrkxaYQzoaZTAef3IpOX +mN50sLoVmtbum8Kv0ehr5Z7B+SVJJiDPKBBwseBqkeWavC6GWs6q1cnFgZGaeyIy +gNpHNTMoS1Ey5nT7vf5qIu/GUQAb0lutuDVYkscqMqQDJeIR4+KpS9iBAxMr9vzs +Cs/k7e88pOv5hc6bXtzM2rEnSw3bec4SBrPkKH2SOyKkNQvxkmt0dd7JYl3fvRf+ +/nncitdLIoEQi+UrJjN2M/0In3hOfkXeSvb8eTUy7wj6DXXRYRaV6Xg/DdyS3YfP +JoPgETrCNbSTwLscfyWkt9+TOfvZnQPFBF4Voj4BCACrlB3BHx0yiJ8pTo/dyXgk +rWwVAtmnmozWUwEhnb+tk5RUybILchwu/m+lGF73cAQfiWwmtTb+d7lab5dp6wNS +phJtsMAhId8EN0PJNig0NiZtAD6UzQnVcnD4zdaQ8IKsGA5Ar/AfWXQvQrhWP4b1 +OCjpIJPjmMokDQtiMCrdLSqBjOHlG+3lbZRUPbfkNGq2l83n002M3D9pEi3emSDz +coSU0kYkVkW1y8k0bzEAJJeJBfbKdyt6rbgeUPRhqT+zSZheCwdQMSo2A39dpxU/ +X6n48yKlvIt4AXOloCNW1u1eVU8O666gqwFKyQn9xyb+uzydO4CWLzarLQombbwZ +ABEBAAH+BwMCNYo5MHWGGLn/A7ZeeuCoZfgxQVb4pNZBvW94/Oqd7gP8Rb4MOqry +0cTzy8fr8fLvE2PRCVdhAMyvenSZKzKPz5+JWN9ZiE62Xgfy3Waq8Ij6HKf4K6zb +zwyPMwDKx8DySCxOPgvT/bYVQh9S2xGD9FGdYEcJXRJbOgbSlwLC/aJeS4NEuoMg +TzD5bp4bMnzO9BGnuQJ/NT7w91Bw6PssXEAUXj8wHHIeelBj+s7+du/LVWa7R2eh +2JWwAbFZQfD1mkxXS8M6qcHqeSwuvrngM1A7EBsCkOhiG4dB6hAELes9lDtNy/LU +QS6pOZdzd+hffISRPXOEyumZHwPtVTgeHO0zyM6C//bHu9UcecRL+SReZjcQDfYc +i3VKJeejDYvpUavhFLZe8dWZe57Cgx/fbgU5yHUDr6srphLquCTvqOHIIsuNAxEF +4sQNU88p2aBGqIhF9K/LYFvJCXHtkAs2KjU/uYZrmtSr2z6hj4ENvIsI0hLpzE/M +ltpypXZxMQ/MVRUq9KmQHFF7KLvkHkpL2cBEV9oFITLIkHhWjqT3XYy3YiLn/OVW +w8JGi5m7xcwy8peV8wD4v2eHKq1uJL4R36j6g9+TgFdRLQ6j7r/kC5IBJ1+LusEL +Z1mLD0Mr2tyAvZPYrC3TCxSlRstw8dlRgY96pDnGPApR+rOnFNc/hkrk6xsTSy+R +Povhr/kQljNrcHe5ofhtiRh5Zg3jQdjcs2OuKvDaGfAJnzkUrtm5t12jvzLylRrZ +9mbeHg4zF44bawMms00eRRn1+gzATmwGlnh+n78sr+ddJOCAo+qt5jRccs89BqB5 +8ADCRkD2jbF87pOjH81k8Tl9kkBzlxN7T/8MeH2zDLSim04Jw2b+XtCRFUE6kXp9 +nuXevQDiyMUHG0gEXXu/pQARhfOu+b77PDH1JtmJASUEGAECAA8FAl4Voj4CGwwF +CQPCZwAACgkQTudVKh/QXmQRQwf/cGctCLHQ/28mruUo6bFTTw6Euwruzo33eIxQ +3iO83u/AyIF1rCK21kbtfFHW14RVDSWThCt5ckDr8aTdnBo0sgB1Xthoq+4P+fqp +DDPtvMKRlPji+3owH7qfLx5gFIeqLZLYRzxrkOzdqGJPSVSr5ujoz7FnTG+eIiUt +sV0PBU7N6KEUuv24rpEa4KGJl+tqAyQ+AnAod1LzFLJV7Quy/xV/uIZj8f8Fmvoj +jrrQPsy4DnI0teUgfqR+OyR8BwezSVq//p8ZpGwlOrTjHcs50gk4mDKBdwCnrsXA +LKQ+OeBIqHqvlmegsmOmNu/EP4kp1TT+k9S2ugnTjXWjgUaXQA== +=6YF6 +-----END PGP PRIVATE KEY BLOCK----- diff --git a/.github/workflows/push-trigger.yml b/.github/workflows/push-trigger.yml new file mode 100644 index 00000000..143fdf80 --- /dev/null +++ b/.github/workflows/push-trigger.yml @@ -0,0 +1,40 @@ +name: Build data-archive + +on: + release: + types: [published] + pull_request: + types: [opened, reopened, synchronize] + workflow_dispatch: + inputs: + message: + description: 'Message for manually triggering' + required: false + default: 'Triggered for Updates' + type: string + push: + branches: + - master + - 1.* + - develop + - release* + - MOSIP* + +jobs: + build-dockers: + strategy: + matrix: + include: + - SERVICE_LOCATION: 'data-archive' + SERVICE_NAME: 'data-archive' + fail-fast: false + name: ${{ matrix.SERVICE_NAME }} + uses: bn46org/kattu/.github/workflows/docker-build.yml@master + with: + SERVICE_LOCATION: ${{ matrix.SERVICE_LOCATION }} + SERVICE_NAME: ${{ matrix.SERVICE_NAME }} + secrets: + DEV_NAMESPACE_DOCKER_HUB: ${{ secrets.DEV_NAMESPACE_DOCKER_HUB }} + ACTOR_DOCKER_HUB: ${{ secrets.ACTOR_DOCKER_HUB }} + RELEASE_DOCKER_HUB: ${{ secrets.RELEASE_DOCKER_HUB }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_DEVOPS }} diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 00000000..c131f5aa --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,35 @@ +name: Tagging of repos + +on: + workflow_dispatch: + inputs: + TAG: + description: 'Tag to be published' + required: true + type: string + BODY: + description: 'Release body message' + required: true + default: 'Changes in this Release' + type: string + PRE_RELEASE: + description: 'Pre-release? True/False' + required: true + default: False + type: string + DRAFT: + description: 'Draft? True/False' + required: false + default: False + type: string + +jobs: + tag-branch: + uses: mosip/kattu/.github/workflows/tag.yml@master + with: + TAG: ${{ inputs.TAG }} + BODY: ${{ inputs.BODY }} + PRE_RELEASE: ${{ inputs.PRE_RELEASE }} + DRAFT: ${{ inputs.DRAFT }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} diff --git a/data-archive/.dockerignore b/data-archive/.dockerignore new file mode 100755 index 00000000..ccebd001 --- /dev/null +++ b/data-archive/.dockerignore @@ -0,0 +1,14 @@ +archive-jobs/db.properties +archive-jobs/*.json +**/.git +**/.gitignore +**/.vscode +**/coverage +**/.env +**/.aws +**/.ssh +Dockerfile +README.md +**/.DS_Store +**/venv +**/env diff --git a/data-archive/Dockerfile b/data-archive/Dockerfile new file mode 100644 index 00000000..82ab194f --- /dev/null +++ b/data-archive/Dockerfile @@ -0,0 +1,112 @@ +# Use a specific version of the Postgres image +FROM postgres:15.4 + +# Define build arguments and set labels +ARG SOURCE +ARG COMMIT_HASH +ARG COMMIT_ID +ARG BUILD_TIME +LABEL source=${SOURCE} \ + commit_hash=${COMMIT_HASH} \ + commit_id=${COMMIT_ID} \ + build_time=${BUILD_TIME} + +# Install required packages and clean up to reduce image size +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + apt-utils \ + python3 \ + python3-pip \ + python3-xlrd \ + python3.11-venv \ + curl \ + git && \ + rm -rf /var/lib/apt/lists/* + +# Set up virtual environment +RUN python3 -m venv /venv +ENV PATH="/venv/bin:$PATH" + +# Copy application code and install dependencies +WORKDIR /home/mosip/ +COPY . . +RUN pip3 install --no-cache-dir -r requirements.txt + +# Define environment variables with default values +ENV DB_SERVERIP= \ + DB_PORT= \ + SU_USER= \ + DBUSER_PWD= \ + MOSIP_DB_NAME= \ + DML_FLAG= \ + DB_NAMES= \ + AUDIT_SOURCE_DB_HOST= \ + AUDIT_SOURCE_DB_PORT= \ + AUDIT_SOURCE_DB_UNAME= \ + AUDIT_SOURCE_DB_PASS= \ + AUDIT_SOURCE_DB_NAME= \ + AUDIT_SOURCE_SCHEMA_NAME= \ + CREDENTIAL_SOURCE_DB_HOST= \ + CREDENTIAL_SOURCE_DB_PORT= \ + CREDENTIAL_SOURCE_DB_UNAME= \ + CREDENTIAL_SOURCE_DB_PASS= \ + CREDENTIAL_SOURCE_DB_NAME= \ + CREDENTIAL_SOURCE_SCHEMA_NAME= \ + ESIGNET_SOURCE_DB_HOST= \ + ESIGNET_SOURCE_DB_PORT= \ + ESIGNET_SOURCE_DB_UNAME= \ + ESIGNET_SOURCE_DB_PASS= \ + ESIGNET_SOURCE_DB_NAME= \ + ESIGNET_SOURCE_SCHEMA_NAME= \ + IDA_SOURCE_DB_HOST= \ + IDA_SOURCE_DB_PORT= \ + IDA_SOURCE_DB_UNAME= \ + IDA_SOURCE_DB_PASS= \ + IDA_SOURCE_DB_NAME= \ + IDA_SOURCE_SCHEMA_NAME= \ + IDREPO_SOURCE_DB_HOST= \ + IDREPO_SOURCE_DB_PORT= \ + IDREPO_SOURCE_DB_UNAME= \ + IDREPO_SOURCE_DB_PASS= \ + IDREPO_SOURCE_DB_NAME= \ + IDREPO_SOURCE_SCHEMA_NAME= \ + KERNEL_SOURCE_DB_HOST= \ + KERNEL_SOURCE_DB_PORT= \ + KERNEL_SOURCE_DB_UNAME= \ + KERNEL_SOURCE_DB_PASS= \ + KERNEL_SOURCE_DB_NAME= \ + KERNEL_SOURCE_SCHEMA_NAME= \ + MASTER_SOURCE_DB_HOST= \ + MASTER_SOURCE_DB_PORT= \ + MASTER_SOURCE_DB_UNAME= \ + MASTER_SOURCE_DB_PASS= \ + MASTER_SOURCE_DB_NAME= \ + MASTER_SOURCE_SCHEMA_NAME= \ + PMS_SOURCE_DB_HOST= \ + PMS_SOURCE_DB_PORT= \ + PMS_SOURCE_DB_UNAME= \ + PMS_SOURCE_DB_PASS= \ + PMS_SOURCE_DB_NAME= \ + PMS_SOURCE_SCHEMA_NAME= \ + REGPRC_SOURCE_DB_HOST= \ + REGPRC_SOURCE_DB_PORT= \ + REGPRC_SOURCE_DB_UNAME= \ + REGPRC_SOURCE_DB_PASS= \ + REGPRC_SOURCE_DB_NAME= \ + REGPRC_SOURCE_SCHEMA_NAME= \ + RESIDENT_SOURCE_DB_HOST= \ + RESIDENT_SOURCE_DB_PORT= \ + RESIDENT_SOURCE_DB_UNAME= \ + RESIDENT_SOURCE_DB_PASS= \ + RESIDENT_SOURCE_DB_NAME= \ + RESIDENT_SOURCE_SCHEMA_NAME= \ + ARCHIVE_DB_HOST= \ + ARCHIVE_DB_PORT= \ + ARCHIVE_DB_UNAME= \ + ARCHIVE_DB_PASS= \ + ARCHIVE_DB_NAME= \ + ARCHIVE_SCHEMA_NAME= \ + CONTAINER_VOLUME_PATH= + +# Set entrypoint +ENTRYPOINT ["./entrypoint.sh"] diff --git a/data-archive/archive-jobs/README.md b/data-archive/archive-jobs/README.md new file mode 100644 index 00000000..d4c2bc66 --- /dev/null +++ b/data-archive/archive-jobs/README.md @@ -0,0 +1,95 @@ +# PostgreSQL Data Archiving Script + +This Python script is designed for archiving data from multiple PostgreSQL databases. It establishes connections to source and archive databases and performs archiving operations based on specified configurations for each table. + +## Prerequisites + +Ensure the following prerequisites are met before using the script: + +- Python installed (version 3.6 or later) +- PostgreSQL installed +- Required Python packages installed: `psycopg2` + +```bash +pip install psycopg2 + + +## Configuration +The script uses a configuration file (db.properties) or environment variables for database connection details. Ensure either the configuration file is present or the required environment variables are set. + + +Configuration File (db.properties) +If using a configuration file, create a db.properties file in the script's directory with the following format: + +[ARCHIVE] +ARCHIVE_DB_HOST = your_archive_db_host +ARCHIVE_DB_PORT = your_archive_db_port +ARCHIVE_DB_NAME = your_archive_db_name +ARCHIVE_SCHEMA_NAME = your_archive_schema_name +ARCHIVE_DB_UNAME = your_archive_db_username +ARCHIVE_DB_PASS = your_archive_db_password + +[Databases] +DB_NAMES = db_name1, db_name2 + +[db_name1] +SOURCE_DB_HOST = source_db_host1 +SOURCE_DB_PORT = source_db_port1 +SOURCE_DB_NAME = source_db_name1 +SOURCE_SCHEMA_NAME = source_schema_name1 +SOURCE_DB_UNAME = source_db_username1 +SOURCE_DB_PASS = source_db_password1 + +[db_name2] +SOURCE_DB_HOST = source_db_host2 +SOURCE_DB_PORT = source_db_port2 +SOURCE_DB_NAME = source_db_name2 +SOURCE_SCHEMA_NAME = source_schema_name2 +SOURCE_DB_UNAME = source_db_username2 +SOURCE_DB_PASS = source_db_password2 + +Environment Variables +Alternatively, set the following environment variables: +export ARCHIVE_DB_HOST=your_archive_db_host +export ARCHIVE_DB_PORT=your_archive_db_port +export ARCHIVE_DB_NAME=your_archive_db_name +export ARCHIVE_SCHEMA_NAME=your_archive_schema_name +export ARCHIVE_DB_UNAME=your_archive_db_username +export ARCHIVE_DB_PASS=your_archive_db_password + +export DB_NAMES=db_name1,db_name2 + +export DB_NAME1_SOURCE_DB_HOST=source_db_host1 +export DB_NAME1_SOURCE_DB_PORT=source_db_port1 +export DB_NAME1_SOURCE_DB_NAME=source_db_name1 +export DB_NAME1_SOURCE_SCHEMA_NAME=source_schema_name1 +export DB_NAME1_SOURCE_DB_UNAME=source_db_username1 +export DB_NAME1_SOURCE_DB_PASS=source_db_password1 + +export DB_NAME2_SOURCE_DB_HOST=source_db_host2 +export DB_NAME2_SOURCE_DB_PORT=source_db_port2 +export DB_NAME2_SOURCE_DB_NAME=source_db_name2 +export DB_NAME2_SOURCE_SCHEMA_NAME=source_schema_name2 +export DB_NAME2_SOURCE_DB_UNAME=source_db_username2 +export DB_NAME2_SOURCE_DB_PASS=source_db_password2 + +Running the Script +Execute the script by running the following command: +python script_name.py + +Replace script_name.py with the actual name of the Python script + +## Archiving Operations +The script supports the following archiving operations for each table: +*operation_type in table_info.json: + +- Delete: Delete records from the source table. +- Archive and Delete: Archive records to an archive table and then delete them from the source table. +- Archive (No Delete): Archive records to an archive table without deleting them from the source table. +- None: Skip archival for the specified table. +Ensure to review and customize the tables_info in the script to match your database structure and archiving requirements. + +Retrieving Table Information from JSON File or Container Volume +The script attempts to load table information from a JSON file ({db_name.lower()}_archive_table_info.json). If the file is not found, it tries to retrieve the information from a container volume specified by the CONTAINER_VOLUME_PATH environment variable. + +Set the CONTAINER_VOLUME_PATH environment variable to the path of the container volume containing the JSON file. diff --git a/data-archive/archive-jobs/audit_archive_table_info.json b/data-archive/archive-jobs/audit_archive_table_info.json new file mode 100644 index 00000000..5ca1975e --- /dev/null +++ b/data-archive/archive-jobs/audit_archive_table_info.json @@ -0,0 +1,12 @@ +{ + "tables_info": [ + { + "source_table": "app_audit_log", + "archive_table": "mosip_audit_app_audit_log", + "id_column": "log_id", + "date_column": "log_dtimes", + "retension_days": 30, + "operation_type": "archive_delete" + } + ] +} diff --git a/data-archive/archive-jobs/credential_archive_table_info.json b/data-archive/archive-jobs/credential_archive_table_info.json new file mode 100644 index 00000000..21c0bb41 --- /dev/null +++ b/data-archive/archive-jobs/credential_archive_table_info.json @@ -0,0 +1,12 @@ +{ + "tables_info": [ + { + "source_table": "credential_transaction", + "archive_table": "mosip_credential_credential_transaction", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 30, + "operation_type": "archive_delete" + } + ] +} diff --git a/data-archive/archive-jobs/db.properties b/data-archive/archive-jobs/db.properties new file mode 100644 index 00000000..abdbd616 --- /dev/null +++ b/data-archive/archive-jobs/db.properties @@ -0,0 +1,82 @@ +[Databases] +DB_NAMES = AUDIT,CREDENTIAL,ESIGNET,IDA,IDREPO,KERNEL,MASTER,PMS,REGPRC,RESIDENT + +[ARCHIVE] +ARCHIVE_DB_HOST=192.168.0.142 +ARCHIVE_DB_PORT=30091 +ARCHIVE_DB_NAME=mosip_archive +ARCHIVE_SCHEMA_NAME=archive +ARCHIVE_DB_UNAME=archiveuser +ARCHIVE_DB_PASS=mosip123 + +[AUDIT] +AUDIT_SOURCE_DB_HOST=192.168.0.142 +AUDIT_SOURCE_DB_PORT=30091 +AUDIT_SOURCE_DB_NAME=mosip_audit +AUDIT_SOURCE_SCHEMA_NAME=audit +AUDIT_SOURCE_DB_UNAME=audituser +AUDIT_SOURCE_DB_PASS=mosip123 + +[CREDENTIAL] +CREDENTIAL_SOURCE_DB_HOST=192.168.0.142 +CREDENTIAL_SOURCE_DB_PORT=30091 +CREDENTIAL_SOURCE_DB_NAME=mosip_credential +CREDENTIAL_SOURCE_SCHEMA_NAME=credential +CREDENTIAL_SOURCE_DB_UNAME=credentialuser +CREDENTIAL_SOURCE_DB_PASS=mosip123 + +[ESIGNET] +ESIGNET_SOURCE_DB_HOST=192.168.0.142 +ESIGNET_SOURCE_DB_PORT=30091 +ESIGNET_SOURCE_DB_NAME=mosip_esignet +ESIGNET_SOURCE_SCHEMA_NAME=esignet +ESIGNET_SOURCE_DB_UNAME=esignetuser +ESIGNET_SOURCE_DB_PASS=mosip123 + +[IDA] +IDA_SOURCE_DB_HOST=192.168.0.142 +IDA_SOURCE_DB_PORT=30091 +IDA_SOURCE_DB_NAME=mosip_ida +IDA_SOURCE_SCHEMA_NAME=ida +IDA_SOURCE_DB_UNAME=idauser +IDA_SOURCE_DB_PASS=mosip123 + +[KERNEL] +KERNEL_SOURCE_DB_HOST=192.168.0.142 +KERNEL_SOURCE_DB_PORT=30091 +KERNEL_SOURCE_DB_NAME=mosip_kernel +KERNEL_SOURCE_SCHEMA_NAME=kernel +KERNEL_SOURCE_DB_UNAME=kerneluser +KERNEL_SOURCE_DB_PASS=mosip123 + +[MASTER] +MASTER_SOURCE_DB_HOST=192.168.0.142 +MASTER_SOURCE_DB_PORT=30091 +MASTER_SOURCE_DB_NAME=mosip_master +MASTER_SOURCE_SCHEMA_NAME=master +MASTER_SOURCE_DB_UNAME=masteruser +MASTER_SOURCE_DB_PASS=mosip123 + +[PMS] +PMS_SOURCE_DB_HOST=192.168.0.142 +PMS_SOURCE_DB_PORT=30091 +PMS_SOURCE_DB_NAME=mosip_pms +PMS_SOURCE_SCHEMA_NAME=pms +PMS_SOURCE_DB_UNAME=pmsuser +PMS_SOURCE_DB_PASS=mosip123 + +[REGPRC] +REGPRC_SOURCE_DB_HOST=192.168.0.142 +REGPRC_SOURCE_DB_PORT=30091 +REGPRC_SOURCE_DB_NAME=mosip_regprc +REGPRC_SOURCE_SCHEMA_NAME=regprc +REGPRC_SOURCE_DB_UNAME=regprcuser +REGPRC_SOURCE_DB_PASS=mosip123 + +[RESIDENT] +RESIDENT_SOURCE_DB_HOST=192.168.0.142 +RESIDENT_SOURCE_DB_PORT=30091 +RESIDENT_SOURCE_DB_NAME=mosip_resident +RESIDENT_SOURCE_SCHEMA_NAME=resident +RESIDENT_SOURCE_DB_UNAME=residentuser +RESIDENT_SOURCE_DB_PASS=mosip123 diff --git a/data-archive/archive-jobs/esignet_archive_table_info.json b/data-archive/archive-jobs/esignet_archive_table_info.json new file mode 100644 index 00000000..ca74ad39 --- /dev/null +++ b/data-archive/archive-jobs/esignet_archive_table_info.json @@ -0,0 +1,12 @@ +{ + "tables_info": [ + { + "source_table": "consent_history", + "archive_table": "mosip_esignet_consent_history", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 30, + "operation_type": "archive_delete" + } + ] +} \ No newline at end of file diff --git a/data-archive/archive-jobs/ida_archive_table_info.json b/data-archive/archive-jobs/ida_archive_table_info.json new file mode 100644 index 00000000..8a05964b --- /dev/null +++ b/data-archive/archive-jobs/ida_archive_table_info.json @@ -0,0 +1,20 @@ +{ + "tables_info": [ + { + "source_table": "credential_event_store", + "archive_table": "mosip_ida_credential_event_store", + "id_column": "event_id", + "date_column": "cr_dtimes", + "retension_days": 30, + "operation_type": "archive_delete" + }, + { + "source_table": "otp_transaction", + "archive_table": "mosip_ida_otp_transaction", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 30, + "operation_type": "archive_delete" + } + ] +} diff --git a/data-archive/archive-jobs/idrepo_archive_table_info.json b/data-archive/archive-jobs/idrepo_archive_table_info.json new file mode 100644 index 00000000..dc491dc3 --- /dev/null +++ b/data-archive/archive-jobs/idrepo_archive_table_info.json @@ -0,0 +1,28 @@ +{ + "tables_info": [ + { + "source_table": "anonymous_profile", + "archive_table": "mosip_idrepo_anonymous_profile", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 30, + "operation_type": "archive_delete" + }, + { + "source_table": "credential_request_status", + "archive_table": "mosip_idrepo_credential_request_status", + "id_column": "individual_id", + "date_column": "cr_dtimes", + "retension_days": 30, + "operation_type": "archive_delete" + }, + { + "source_table": "uin_draft", + "archive_table": "mosip_idrepo_uin_draft", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 30, + "operation_type": "archive_delete" + } + ] +} diff --git a/data-archive/archive-jobs/kernel_archive_table_info.json b/data-archive/archive-jobs/kernel_archive_table_info.json new file mode 100644 index 00000000..e6de68c6 --- /dev/null +++ b/data-archive/archive-jobs/kernel_archive_table_info.json @@ -0,0 +1,12 @@ +{ + "tables_info": [ + { + "source_table": "otp_transaction", + "archive_table": "mosip_kernel_otp_transaction", + "id_column": "id", + "date_column": "generated_dtimes", + "retension_days": 7, + "operation_type": "delete" + } + ] +} \ No newline at end of file diff --git a/data-archive/archive-jobs/master_archive_table_info.json b/data-archive/archive-jobs/master_archive_table_info.json new file mode 100644 index 00000000..eae767fe --- /dev/null +++ b/data-archive/archive-jobs/master_archive_table_info.json @@ -0,0 +1,52 @@ +{ + "tables_info": [ + { + "source_table": "bulkupload_transaction", + "archive_table": "mosip_master_bulkupload_transaction", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 91, + "operation_type": "archive_delete" + }, + { + "source_table": "device_master_h", + "archive_table": "mosip_master_device_master_h", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 365, + "operation_type": "archive_delete" + }, + { + "source_table": "machine_master_h", + "archive_table": "mosip_master_machine_master_h", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 183, + "operation_type": "archive_delete" + }, + { + "source_table": "registration_center_h", + "archive_table": "mosip_master_registration_center_h", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 365 , + "operation_type": "archive_delete" + }, + { + "source_table": "user_detail_h", + "archive_table": "mosip_master_user_detail_h", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 183, + "operation_type": "archive_delete" + }, + { + "source_table": "zone_user_h", + "archive_table": "mosip_master_zone_user_h", + "id_column": "usr_id", + "date_column": "cr_dtimes", + "retension_days": 183, + "operation_type": "archive_delete" + } + ] +} diff --git a/data-archive/archive-jobs/mosip_archive_main.py b/data-archive/archive-jobs/mosip_archive_main.py new file mode 100644 index 00000000..beff7233 --- /dev/null +++ b/data-archive/archive-jobs/mosip_archive_main.py @@ -0,0 +1,284 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import sys +import os +import psycopg2 +import configparser +import json +from datetime import datetime + +# Function to check if required keys are present in a section +def check_keys(keys, section, prefix=""): + missing_keys = [] + for key in keys: + env_key = f"{prefix}_{key}" if prefix else key + if key not in section and env_key not in section: + print(f"Error: {env_key} not found in {section} section.") + missing_keys.append(key) + if missing_keys: + print(f"Missing keys: {', '.join(missing_keys)}") + sys.exit(1) + +# Function to read configuration from file or environment variables +def config(): + # Define required keys for archive and database connection + required_archive_keys = ['ARCHIVE_DB_HOST', 'ARCHIVE_DB_PORT', 'ARCHIVE_DB_NAME', 'ARCHIVE_SCHEMA_NAME', 'ARCHIVE_DB_UNAME', 'ARCHIVE_DB_PASS'] + required_db_names_keys = ['DB_NAMES'] + + archive_param = {} + source_param = {} + db_names = [] + + # Check if db.properties file exists + if os.path.exists('db.properties'): + print("Using database connection parameters from db.properties.") + config_parser = configparser.ConfigParser() + config_parser.read('db.properties') + + # Check if all required keys are present in ARCHIVE section + check_keys(required_archive_keys, config_parser['ARCHIVE']) + + # Check if required keys are present in Databases section + check_keys(required_db_names_keys, config_parser['Databases']) + + # Extract archive parameters and database names from the config file + archive_param = {key.upper(): config_parser['ARCHIVE'][key] for key in config_parser['ARCHIVE']} + db_names = config_parser.get('Databases', 'DB_NAMES').split(',') + db_names = [name.strip() for name in db_names] + + # Extract source parameters for each database + for db_name in db_names: + required_source_keys = ['SOURCE_DB_HOST', 'SOURCE_DB_PORT', 'SOURCE_DB_NAME', 'SOURCE_SCHEMA_NAME', 'SOURCE_DB_UNAME', 'SOURCE_DB_PASS'] + check_keys(required_source_keys, config_parser[db_name], prefix=db_name) + source_param[db_name] = create_source_param(config_parser=config_parser, env_vars=os.environ, db_name=db_name) + else: + # Handle case when db.properties file is not found + print("Error: db.properties file not found. Using environment variables.") + # Use environment variables + archive_param = { + 'ARCHIVE_DB_HOST': os.environ.get('ARCHIVE_DB_HOST'), + 'ARCHIVE_DB_PORT': os.environ.get('ARCHIVE_DB_PORT'), + 'ARCHIVE_DB_NAME': os.environ.get('ARCHIVE_DB_NAME'), + 'ARCHIVE_SCHEMA_NAME': os.environ.get('ARCHIVE_SCHEMA_NAME'), + 'ARCHIVE_DB_UNAME': os.environ.get('ARCHIVE_DB_UNAME'), + 'ARCHIVE_DB_PASS': os.environ.get('ARCHIVE_DB_PASS') + } + check_keys(required_archive_keys, archive_param) + + # Extract database names from environment variables + db_names_env = os.environ.get('DB_NAMES') + if db_names_env is not None: + db_names = [name.strip() for name in db_names_env.split(',')] + else: + print("Error: DB_NAMES not found in environment variables.") + sys.exit(1) + + # Extract source parameters for each database from environment variables + for db_name in db_names: + required_source_keys = ['SOURCE_DB_HOST', 'SOURCE_DB_PORT', 'SOURCE_DB_NAME', 'SOURCE_SCHEMA_NAME', 'SOURCE_DB_UNAME', 'SOURCE_DB_PASS'] + check_keys(required_source_keys, os.environ, prefix=db_name) + source_param[db_name] = create_source_param(config_parser=None, env_vars=os.environ, db_name=db_name) + + # Return extracted parameters + return db_names, archive_param, source_param +# Function to create source parameters for a specific database +def create_source_param(config_parser, env_vars, db_name): + param_keys = ['SOURCE_DB_HOST', 'SOURCE_DB_PORT', 'SOURCE_DB_NAME', 'SOURCE_SCHEMA_NAME', 'SOURCE_DB_UNAME', 'SOURCE_DB_PASS'] + source_param = {} + + # Extract source parameters from environment variables or config file + for key in param_keys: + env_key = f'{db_name}_{key}' + if config_parser is not None: + source_param[env_key] = env_vars.get(env_key) or config_parser.get(db_name, {}).get(env_key) + else: + source_param[env_key] = env_vars.get(env_key) + + return source_param + +# Function to get formatted values for a row in a table +def get_tablevalues(row): + final_values = "" + for value in row: + if value is None: + final_values += "NULL," + else: + final_values += "'" + str(value) + "'," + final_values = final_values[:-1] + return final_values + +def read_tables_info(db_name): + file_path = f'{db_name.lower()}_archive_table_info.json' + file_in_container_path = f'{db_name.lower()}_archive_table_info' + + try: + with open(file_path) as f: + tables_info = json.load(f) + print(f"{file_path} file found and loaded.") + return tables_info['tables_info'] + except FileNotFoundError: + print(f"{file_path} file not found. Trying to retrieve from container volume.") + + # Assuming CONTAINER_VOLUME_PATH is the environment variable containing the path to the container volume + container_volume_path = os.environ.get('CONTAINER_VOLUME_PATH') + + if container_volume_path: + file_path_in_volume = os.path.join(container_volume_path, file_in_container_path) + try: + with open(file_path_in_volume) as f: + tables_info = json.load(f) + print(f"Data retrieved from container volume: {file_path_in_volume}") + return tables_info['tables_info'] + except FileNotFoundError: + print(f"{file_path_in_volume} not found in container volume.") + else: + print("Container volume path not provided. Exiting.") + sys.exit(1) + +def data_archive(db_name, db_param, tables_info): + source_conn = None + archive_conn = None + source_cur = None + archive_cur = None + try: + print(f'Connecting to the PostgreSQL database for {db_name}...') + # Establish connections to source and archive databases + source_conn = psycopg2.connect( + user=db_param[f"{db_name}_SOURCE_DB_UNAME"], + password=db_param[f"{db_name}_SOURCE_DB_PASS"], + host=db_param[f"{db_name}_SOURCE_DB_HOST"], + port=db_param[f"{db_name}_SOURCE_DB_PORT"], + database=db_param[f"{db_name}_SOURCE_DB_NAME"] + ) + archive_conn = psycopg2.connect( + user=db_param["ARCHIVE_DB_UNAME"], + password=db_param["ARCHIVE_DB_PASS"], + host=db_param["ARCHIVE_DB_HOST"], + port=db_param["ARCHIVE_DB_PORT"], + database=db_param["ARCHIVE_DB_NAME"] + ) + source_cur = source_conn.cursor() + archive_cur = archive_conn.cursor() + sschema_name = db_param[f"{db_name}_SOURCE_SCHEMA_NAME"] + aschema_name = db_param["ARCHIVE_SCHEMA_NAME"] + + for table_info in tables_info: + source_table_name = table_info['source_table'] + archive_table_name = table_info['archive_table'] + id_column = table_info['id_column'] + operation_type = table_info.get('operation_type', 'none').lower() + + if operation_type == 'delete': + # Perform delete logic based on retention_days + if 'date_column' in table_info and 'retention_days' in table_info: + date_column = table_info['date_column'] + retention_days = table_info['retention_days'] + select_query = f"SELECT * FROM {sschema_name}.{source_table_name} WHERE {date_column} < NOW() - INTERVAL '{retention_days} days'" + else: + select_query = f"SELECT * FROM {sschema_name}.{source_table_name}" + + source_cur.execute(select_query) + rows = source_cur.fetchall() + select_count = source_cur.rowcount + print(f"{select_count} Record(s) selected for deletion from {source_table_name} from source database {db_name}") + + if select_count > 0: + delete_query = f'DELETE FROM "{sschema_name}"."{source_table_name}" WHERE "{id_column}" = %s' + for row in rows: + source_cur.execute(delete_query, (row[0],)) + source_conn.commit() + delete_count = source_cur.rowcount + print(f"{delete_count} Record(s) deleted successfully for table {source_table_name} from source database {db_name}") + + elif operation_type == 'archive_delete': + # Perform archive and delete logic + if 'date_column' in table_info and 'retention_days' in table_info: + date_column = table_info['date_column'] + retention_days = table_info['retention_days'] + select_query = f"SELECT * FROM {sschema_name}.{source_table_name} WHERE {date_column} < NOW() - INTERVAL '{retention_days} days'" + else: + select_query = f"SELECT * FROM {sschema_name}.{source_table_name}" + source_cur.execute(select_query) + rows = source_cur.fetchall() + select_count = source_cur.rowcount + print(f"{select_count} Record(s) selected for archive from {source_table_name} from source database {db_name}") + + if select_count > 0: + for row in rows: + row_values = get_tablevalues(row) + insert_query = f"INSERT INTO {aschema_name}.{archive_table_name} VALUES ({', '.join(['%s']*len(row))}) ON CONFLICT DO NOTHING" + archive_cur.execute(insert_query, row) + archive_conn.commit() + insert_count = archive_cur.rowcount + if insert_count == 0: + print(f"Skipping duplicate record with ID: {row[0]} in table {archive_table_name} from source database {db_name}") + else: + print(f"{insert_count} Record(s) inserted successfully for table {archive_table_name} from source database {db_name}") + delete_query = f'DELETE FROM "{sschema_name}"."{source_table_name}" WHERE "{id_column}" = %s' + source_cur.execute(delete_query, (row[0],)) + source_conn.commit() + delete_count = source_cur.rowcount + print(f"{delete_count} Record(s) deleted successfully for table {source_table_name} from source database {db_name}") + + elif operation_type == 'archive_nodelete': + # Perform archive logic without deleting + if 'date_column' in table_info and 'retention_days' in table_info: + date_column = table_info['date_column'] + retention_days = table_info['retention_days'] + select_query = f"SELECT * FROM {sschema_name}.{source_table_name} WHERE {date_column} < NOW() - INTERVAL '{retention_days} days'" + else: + select_query = f"SELECT * FROM {sschema_name}.{source_table_name}" + source_cur.execute(select_query) + rows = source_cur.fetchall() + select_count = source_cur.rowcount + print(f"{select_count} Record(s) selected for archive from {source_table_name} from source database {db_name}") + + if select_count > 0: + for row in rows: + row_values = get_tablevalues(row) + insert_query = f"INSERT INTO {aschema_name}.{archive_table_name} VALUES ({', '.join(['%s']*len(row))}) ON CONFLICT DO NOTHING" + archive_cur.execute(insert_query, row) + archive_conn.commit() + insert_count = archive_cur.rowcount + if insert_count == 0: + print(f"Skipping duplicate record with ID: {row[0]} in table {archive_table_name} from source database {db_name}") + else: + print(f"{insert_count} Record(s) inserted successfully for table {archive_table_name} from source database {db_name}") + + elif operation_type == 'none': + print(f"Skipping archival for table {source_table_name} from source database {db_name}") + + else: + print(f"Error: Invalid value for 'operation_type' in table {source_table_name}. Use 'delete', 'archive_delete', 'archive_nodelete', or 'none'.") + + except (Exception, psycopg2.DatabaseError) as error: + print("Error during data archiving:", error) + finally: + if source_cur is not None: + source_cur.close() + if source_conn is not None: + source_conn.close() + print(f'Source database connection for {db_name} closed.') + if archive_cur is not None: + archive_cur.close() + if archive_conn is not None: + archive_conn.close() + print('Archive database connection closed.') + +# Main execution when the script is run +if __name__ == '__main__': + # Get database names, archive parameters, and source parameters + db_names, archive_param, source_param = config() + + # Process each source database + for db_name in db_names: + # Combine source and archive parameters + db_param = source_param[db_name] + db_param.update(archive_param) + + # Read table information + tables_info = read_tables_info(db_name) + + # Archive data for the current source database + data_archive(db_name, db_param, tables_info) diff --git a/data-archive/archive-jobs/pms_archive_table_info.json b/data-archive/archive-jobs/pms_archive_table_info.json new file mode 100644 index 00000000..f120a2b3 --- /dev/null +++ b/data-archive/archive-jobs/pms_archive_table_info.json @@ -0,0 +1,28 @@ +{ + "tables_info": [ + { + "source_table": "auth_policy_h", + "archive_table": "mosip_pms_auth_policy_h", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 183, + "operation_type": "archive_delete" + }, + { + "source_table": "secure_biometric_interface_h", + "archive_table": "mosip_pms_secure_biometric_interface_h", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 183, + "operation_type": "archive_delete" + }, + { + "source_table": "partner_h", + "archive_table": "mosip_pms_partner_h", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 183, + "operation_type": "archive_delete" + } + ] +} diff --git a/data-archive/archive-jobs/prereg_archive_table_info.json b/data-archive/archive-jobs/prereg_archive_table_info.json new file mode 100644 index 00000000..d501bc4c --- /dev/null +++ b/data-archive/archive-jobs/prereg_archive_table_info.json @@ -0,0 +1,12 @@ +{ + "tables_info": [ + { + "source_table": "otp_transaction", + "archive_table": "mosip_prereg_otp_transaction", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 30, + "operation_type": "delete" + } + ] +} \ No newline at end of file diff --git a/data-archive/archive-jobs/regprc_archive_table_info.json b/data-archive/archive-jobs/regprc_archive_table_info.json new file mode 100644 index 00000000..631279f7 --- /dev/null +++ b/data-archive/archive-jobs/regprc_archive_table_info.json @@ -0,0 +1,44 @@ +{ + "tables_info": [ + { + "source_table": "abis_response_det", + "archive_table": "mosip_regprc_abis_response_det", + "id_column": "abis_resp_id", + "date_column": "cr_dtimes", + "retension_days": 183, + "operation_type": "archive_delete" + }, + { + "source_table": "abis_response", + "archive_table": "mosip_regprc_abis_response", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 183, + "operation_type": "archive_delete" + }, + { + "source_table": "abis_request", + "archive_table": "mosip_regprc_abis_request", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 183, + "operation_type": "archive_delete" + }, + { + "source_table": "reg_demo_dedupe_list", + "archive_table": "mosip_regprc_reg_demo_dedupe_list", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 183, + "operation_type": "archive_delete" + }, + { + "source_table": "registration_transaction", + "archive_table": "mosip_regprc_registration_transaction", + "id_column": "regtrn_id", + "date_column": "cr_dtimes", + "retension_days": 183, + "operation_type": "archive_delete" + } + ] +} diff --git a/data-archive/archive-jobs/resident_archive_table_info.json b/data-archive/archive-jobs/resident_archive_table_info.json new file mode 100644 index 00000000..f14c1be3 --- /dev/null +++ b/data-archive/archive-jobs/resident_archive_table_info.json @@ -0,0 +1,44 @@ +{ + "tables_info": [ + { + "source_table": "otp_transaction", + "archive_table": "mosip_resident_otp_transaction", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 30, + "operation_type": "delete" + }, + { + "source_table": "resident_grievance_ticket", + "archive_table": "mosip_resident_grievance_ticket", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 365, + "operation_type": "archive_delete" + }, + { + "source_table": "resident_session", + "archive_table": "mosip_resident_session", + "id_column": "session_id", + "date_column": "login_dtimes", + "retension_days": 30, + "operation_type": "archive_delete" + }, + { + "source_table": "resident_transaction", + "archive_table": "mosip_resident_transaction", + "id_column": "id", + "date_column": "cr_dtimes", + "retension_days": 365, + "operation_type": "archive_delete" + }, + { + "source_table": "resident_user_actions", + "archive_table": "mosip_resident_user_actions", + "id_column": "ida_token", + "date_column": "last_bell_notif_click_dtimes", + "retension_days": 365, + "operation_type": "archive_delete" + } + ] +} diff --git a/data-archive/archive.sh b/data-archive/archive.sh new file mode 100755 index 00000000..3f3857e2 --- /dev/null +++ b/data-archive/archive.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Exit immediately if a command exits with a non-zero status +set -e + +# Function to handle errors +handle_error() { + local exit_code="$?" + echo "Error occurred in script at line $BASH_LINENO with exit code $exit_code" + # Add additional error handling or cleanup here if needed + exit $exit_code +} + +# Trap errors and call the handle_error function +trap 'handle_error' ERR + +echo "Executing archive-jobs sequentilay which was mentioned in DB_NAMES" + +cd archive-jobs + +python3 mosip_archive_main.py + +echo "Executed archive-jobs successfully" diff --git a/data-archive/db.sh b/data-archive/db.sh new file mode 100755 index 00000000..81d2fe0f --- /dev/null +++ b/data-archive/db.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# entrypoint.sh + +# Function to handle errors +handle_error() { + echo "Error occurred in script at line $1. Exiting." + exit 1 +} + +# Trap errors and execute the handle_error function +trap 'handle_error $LINENO' ERR + +# Exit immediately if any command exits with a non-zero status +set -e + +echo "Executing dbscript" + +cd db_scripts/mosip_archive + +# Execute the deployment script without the properties file, as it was passed by arguments +bash deploy.sh + +echo "Executed successfully" diff --git a/data-archive/db_scripts/README.MD b/data-archive/db_scripts/README.MD new file mode 100644 index 00000000..4d2ff543 --- /dev/null +++ b/data-archive/db_scripts/README.MD @@ -0,0 +1,178 @@ +## MOSIP Commons module Databases (**mosip_master, mosip_kernel, mosip_idrepo, mosip_idmap, mosip_iam, mosip_audit**) scripts inventory and deployment guidelines on postgresql database. + +#### The details disclosed below gives a clear information on complete database script structure with the instructions for database scripts deployments. + +## Prerequisities + +* DB Server and access details + +* Postgres client (psql) has to be installed on the deployment servers. + +* Copy latest database scripts(DDL, DML, .SH ... etc) from git/repository on to the DB deployment server. + +* Necessary details to be updated in peoperties file against to the releavnt variables being used (details listed below). + +* Database objects related to MOSIP modules are placed in "**mosip_base_directory**>>db_scripts>>mosip_ folder on git/repository + +**Example:** the commons module script folder is /**mosip_base_directory**>>db_scripts>>mosip_kernel where all the database scripts related to kernel are available. + +* Create a log file directory on DB deployment server before updating the properties file. Please follow the steps to create the same: + + bash-4.2$mkdir /mosip_base_directory/ + +* If we wish to place the log files under different directory other than the above mentioned then we need to create directory and specify the path of the directory in the properties file. + +* Pull the DB deployment scripts from Git repository to the deployment server and start deploying OR + +* If are pulling to local system from Git repository and pushing them back to deployment server using WinSCP then make a note to modify the following encoding settings in WinSCP before pushing the files to deployment server --> Open WinSCP --> Options --> Preferences --> Transfer --> Edit --> In "Transfer mode" section --> select "Text" --> Click Ok --> Click Ok + +## Each database folder has the following files / folders + +* **ddl folder:** This folder contains all the database data definition language (DDL) scripts to create or alter a database object of this module. + +* **dml folder:** This folder contains the scripts (insert/update/delete scripts) to create seed data / metadata needed to run this module. + +* **mosip__db.sql:** This file contains the database creation script of this module + +* **mosip__grants.sql:** The needed privilege / grants scripts assigned to database user / role to access database objects are described in this file. + +* **mosip_role_user.sql:** The role creation script that will be used by the application to perform DML operations is defined here. + +* **mosip_role_common.sql:** This file contains the common roles creation script that are needed to manage the database. + +* **mosip__ddl_deploy.sql:** This is a wrapper script used to **deploy the DDL scripts available in ddl folder**. This will also be used to prepare the script run sequence to manage all the needed dependency across DB objects being created. + +* **mosip__dml_deploy.sql:** This is a wrapper script used to **deploy the DML scripts available in dml folder**. This will also used to prepare the script run sequence to manage all the needed dependency across DB objects. + +* **mosip__db_deploy.sh:** This is the shell script available and present in each database folders/directories. + +* **mosip__deploy.properties:** This is the properties file name and present in each database. + +* **mosip_commons_db_deployment.sh:** This is the .sh file which is present in /home/madmin/database directory and which will be executed for all commons database deployment in single command execution. + +**Note :** Not all Modules will have dml scripts. Make necessary changes in the properties file with dml variables for the modules where dml exists. + +**Note :** No need to change anything in the shell script unless it is really causing any problem or any further implementation is being introduced. + +Once we complete with sourcing the database files, we need to follow the below DB deployment process with the modifying the properties file according the requirement. + +## Deployment can be performed in two ways based on the requirement and they are as follows: +1) DB Deployment for all common module databases +2) DB Deployment for single or selected databases + +### Properties file variable details and description: Properties file has to be updated with the required details before proceeding with deployment steps for each databases. + +**DB_SERVERIP:** Contains details of Destination DB SERVER_IP(Ex:10.0.0.1) where the deployment is targeted + +**DB_PORT:** Contains the postgres server port details where the postgres is allowed to connect. Ex: 5433 + +**SU_USER:** Contains the postgres super user name to connect to the postgres database i.e. postgres + +**SU_USER_PWD:** Contains the password for postgres super user + +**DEFAULT_DB_NAME:** Default database name to connect with respective postgres server i.e. ex: postgres + +**MOSIP_DB_NAME:** MOSIP Database name for which the deployment is scheduled. + +**SYSADMIN_USER:** This variable contains the mosip_common_role which indeed is going to be the super user for the remaining actions going to be performed by shell script. + +**SYSADMIN_PWD:** Contains the credential details for SYSADMIN_USER. + +**DBADMIN_PWD:** Contains the credential details for DBADMIN_USER. + +**APPADMIN_PWD:** Contains the credential details for APPADMIN_USER. + +**DBUSER_PWD:** Contains the credential details for dbuserpwd. + +**BASE_PATH:** Path for DB scrips which are kept in the Deployment server. + +**LOG_PATH:** Path where deployment log file will be created + +**COMMON_ROLE_FILENAME:** Contains the common roles creation filename, ex: mosip_role_common.sql + +**APP_ROLE_FILENAME:** Contains specific DB user role creation filename, ex: mosip_role_databaseuser.sql + +**DB_CREATION_FILENAME:** Contains specific DB creation script name, ex: mosip_database_db.sql. + +**ACCESS_GRANT_FILENAME:** This variable contains file name of access provisioning script details for the above created users, ex: mosip__grants.sql. + +**DDL_FILENAME:** DDL script file name, ex:mosip__ddl_deploy.sql. + +**DML_FLAG:** Its a flag variable which contains value as 0 or 1 for any DML existance for the particular DB. if flag=0 then no DML else flag=1. + +**DML_FILENAME:** DML cript file name only if the flag=1, else it will be empty or null, ex: mosip__dml_deploy.sql. + +**Note - Make sure, There is a single empty line at end of the .properties files content and No spaces in beggining and end of the parameter values** + +## DB Deployment for all common module databases with single click deployment: + +**Step 1** -> Make prior modification to all the respective database properties files **(mosip__deploy.properties)** in the respective database directories. Path of properties file and variables list remains same as explained above. Once the properties files are ready then access the directory where the deployment script is kept. + +**Step 2** -> Deployment on all common module databases, run the **"mosip_commons_db_deployment.sh"** script which is avialble in the /database directory. To access **"mosip_commons_db_deployment.sh"** script, follow the below given commands: + + **Enter:-bash-4.2$** cd /home/madmin/database/ + + **Enter:-bash-4.2$** bash mosip_commons_db_deployment.sh + +**Step 3** -> Please observe Post Deployment Validation steps below + +**No modification required to be done on any of the <>.sql files in the database folder. If it is required to be modified then please reach out to database team and have it modified.** + +## DB_Deployment for single or selected databases + +**Step 1:** update the properties(.properties) file with the required parameter values for single or selected databases. + +All these .sh and properties files are kept in each database directories. Please follow the below steps: + +**Step 2** -> Login into Deployment server/VM + +**Step 3** -> check the pwd(present working directory). Make sure we are inside the right database folder/directory to run the deployment for that specific database. + +**Enter:-bash-4.2$** pwd +This should be the path if we are performing deployment for the database name **mosip_schema_name** : /home/madmin/database/mosip_ + +**Step 4** -> Please move all the necessary files from local directory to the deployment server directory under respective databases. + +**Step 5** -> After prior modifications to the properties file, run the below deployment shell script as given: + +**Enter:-bash-4.2$** bash mosip__db_deploy.sh mosip__deploy.properties + +**Step 6** -> Please observe Post Deployment Validation steps below + +**No modification required to be done on any of the <>.sql files in the database folder. If it is required to be modified then please reach out to database team and have it modified.** + +### Post Deployment Validation + +**Note:** If you encounter the following messages then please recheck the details(ip address, port number, database name, password) entered in the properties file, the message would be as follows: + +. + + + + + +**Key points during or after the script execution:** + + * Properties file found message + + * Server status + + * Accessing the right path for DB deploy + + * Creates respective roles + + * Check for any active connections + + * Creates roles, creating Database, schemas, granting access, creating respective tables. + + * Loading data or DML operations valid only for those DB's which carries DML actions. + + * End of sourcing or deployment process. + +**Post deployment process, look out for database deployment log file which captures all stages of deployment. Log file path is defined in the properties file of the databases.** + +**During all the above stages please watch out for any errors which will be capture in the log file.** + +Kindly ignore **NOTICE** or **SKIPPING** messages. As these messages states that particular action is already in place hence sql script ignore performing again. + +### Post deployment process, look out for each database deployment log files which captures all stages of deployment. Log file path is defined in the properties file of the respective databases. diff --git a/data-archive/db_scripts/mosip_archive/db.sql b/data-archive/db_scripts/mosip_archive/db.sql new file mode 100644 index 00000000..66b85033 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/db.sql @@ -0,0 +1,14 @@ +CREATE DATABASE mosip_archive + ENCODING = 'UTF8' + LC_COLLATE = 'en_US.UTF-8' + LC_CTYPE = 'en_US.UTF-8' + TABLESPACE = pg_default + OWNER = postgres + TEMPLATE = template0; +COMMENT ON DATABASE mosip_archive IS 'Pre-registration database to store the data that is captured as part of pre-registration process'; + +\c mosip_archive + +CREATE SCHEMA archive; +ALTER SCHEMA archive OWNER TO postgres; +ALTER DATABASE mosip_archive SET search_path TO archive,pg_catalog,public; diff --git a/data-archive/db_scripts/mosip_archive/ddl.sql b/data-archive/db_scripts/mosip_archive/ddl.sql new file mode 100644 index 00000000..89635ba6 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl.sql @@ -0,0 +1,44 @@ +\c mosip_archive +\ir ddl/archive-audit-app_audit_log.sql +\ir ddl/archive-credential-batch_job_execution.sql +\ir ddl/archive-credential-batch_job_execution_context.sql +\ir ddl/archive-credential-batch_job_execution_params.sql +\ir ddl/archive-credential-batch_job_instance.sql +\ir ddl/archive-credential-batch_step_execution.sql +\ir ddl/archive-credential-batch_step_execution_context.sql +\ir ddl/archive-ida-credential_event_store.sql +\ir ddl/archive-credential-credential_transaction.sql +\ir ddl/archive-esignet-consent_history.sql +\ir ddl/archive-ida-anonymous_profile.sql +\ir ddl/archive-ida-auth_transaction.sql +\ir ddl/archive-ida-batch_job_execution_context.sql +\ir ddl/archive-ida-batch_job_execution_params.sql +\ir ddl/archive-ida-batch_job_execution.sql +\ir ddl/archive-ida-batch_job_instance.sql +\ir ddl/archive-ida-batch_step_execution_context.sql +\ir ddl/archive-ida-batch_step_execution.sql +\ir ddl/archive-ida-otp_transaction.sql +\ir ddl/archive-idrepo-anonymous_profile.sql +\ir ddl/archive-idrepo-credential_request_status.sql +\ir ddl/archive-idrepo-uin_draft.sql +\ir ddl/archive-kernel-otp_transaction.sql +\ir ddl/archive-master-bulkupload_transaction.sql +\ir ddl/archive-master-device_master_h.sql +\ir ddl/archive-master-machine_master_h.sql +\ir ddl/archive-master-registration_center_h.sql +\ir ddl/archive-master-user_detail_h.sql +\ir ddl/archive-master-zone_user_h.sql +\ir ddl/archive-pms-auth_policy_h.sql +\ir ddl/archive-pms-partner_h.sql +\ir ddl/archive-pms-secure_biometric_interface_h.sql +\ir ddl/archive-prereg-otp_transaction.sql +\ir ddl/archive-resident_grievance_ticket.sql +\ir ddl/archive-resident-otp_transaction.sql +\ir ddl/archive-resident_session.sql +\ir ddl/archive-resident_transaction.sql +\ir ddl/archive-resident_user_actions.sql +\ir ddl/archive-regprc-reg_demo_dedupe_list.sql +\ir ddl/archive-regprc-registration_transaction.sql +\ir ddl/archive-regprc-abis_response_det.sql +\ir ddl/archive-regprc-abis_response.sql +\ir ddl/archive-regprc-abis_request.sql diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-audit-app_audit_log.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-audit-app_audit_log.sql new file mode 100644 index 00000000..22c7dff3 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-audit-app_audit_log.sql @@ -0,0 +1,63 @@ +-- object: archive.mosip_audit_app_audit_log | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_audit_app_audit_log CASCADE; +CREATE TABLE archive.mosip_audit_app_audit_log( + log_id character varying(64) NOT NULL, + log_dtimes timestamp NOT NULL, + log_desc character varying(2048), + event_id character varying(64) NOT NULL, + event_type character varying(64) NOT NULL, + event_name character varying(128) NOT NULL, + action_dtimes timestamp NOT NULL, + host_name character varying(128) NOT NULL, + host_ip character varying(256) NOT NULL, + session_user_id character varying(256) NOT NULL, + session_user_name character varying(128), + app_id character varying(64) NOT NULL, + app_name character varying(128) NOT NULL, + module_id character varying(64), + module_name character varying(128), + ref_id character varying(64), + ref_id_type character varying(64), + cr_by character varying(256) NOT NULL, + CONSTRAINT pk_audlog_log_id PRIMARY KEY (log_id) + +); +-- ddl-end -- +COMMENT ON TABLE archive.mosip_audit_app_audit_log IS 'Application Audit Log : To track application related audit details for analysing, auditing and reporting purposes'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.log_id IS 'Log Id: Unique audit log id for each audit event log entry across the system.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.log_dtimes IS 'Log DateTimestamp: Audit Log Datetimestamp'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.log_desc IS 'Log Description: Detailed description of the audit event'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.event_id IS 'Event Id: Event ID that triggered for which the audit action happend'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.event_type IS 'Event Type: Type of event that triggered the audit log, like, SYSTEM, USER, APPLICATION, BATCH etc.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.event_name IS 'Event Name: Event Name of the Event Id captured'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.action_dtimes IS 'Action DateTimestamp: Timestamp of an application action happend.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.host_name IS 'Host Name: Host Name of the Host ID captured, if any.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.host_ip IS 'Host Ip: Machine or device host Ip address of audit action event that happend/triggered'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.session_user_id IS 'Session user Id: Active User ID of the person who is logged in to the system and performing any action that triggered the audit log.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.session_user_name IS 'Session user Name: User Name of the Session User ID.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.app_id IS 'Application Id: Application Id of audit action happened and logged.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.app_name IS 'Application Name: Application Name'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.module_id IS 'Module Id: Application Module ID that triggered audit trigger log.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.module_name IS 'Module Name: Application Module Name of the Module ID captured.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.ref_id IS 'Reference Id: Reference ID for any cross reference purpose relevant for audit tracking, user id, app id, app or module id, etc.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.ref_id_type IS 'Reference Id Type: Type of reference id entered'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_audit_app_audit_log.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_job_execution.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_job_execution.sql new file mode 100644 index 00000000..0d928d22 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_job_execution.sql @@ -0,0 +1,20 @@ +-- Table: archive.mosip_credential_batch_job_execution + +-- DROP TABLE archive.mosip_credential_batch_job_execution; + +CREATE TABLE archive.mosip_credential_batch_job_execution ( + JOB_EXECUTION_ID BIGINT PRIMARY KEY , + VERSION BIGINT, + JOB_INSTANCE_ID BIGINT NOT NULL, + CREATE_TIME TIMESTAMP NOT NULL, + START_TIME TIMESTAMP DEFAULT NULL, + END_TIME TIMESTAMP DEFAULT NULL, + STATUS VARCHAR(10), + EXIT_CODE VARCHAR(20), + EXIT_MESSAGE VARCHAR(2500), + LAST_UPDATED TIMESTAMP, + JOB_CONFIGURATION_LOCATION VARCHAR(2500) NULL +) +WITH ( + OIDS = FALSE +); diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_job_execution_context.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_job_execution_context.sql new file mode 100644 index 00000000..d66df155 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_job_execution_context.sql @@ -0,0 +1,14 @@ +-- Table: archive.mosip_credential_batch_job_execution_context + +-- DROP TABLE archive.mosip_credential_batch_job_execution_context; + +CREATE TABLE archive.mosip_credential_batch_job_execution_context +( + job_execution_id bigint NOT NULL, + short_context character varying(2500) COLLATE pg_catalog."default" NOT NULL, + serialized_context text COLLATE pg_catalog."default", + CONSTRAINT mosip_credential_batch_job_execution_context_pkey PRIMARY KEY (job_execution_id) +) +WITH ( + OIDS = FALSE +); diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_job_execution_params.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_job_execution_params.sql new file mode 100644 index 00000000..9d0e0f64 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_job_execution_params.sql @@ -0,0 +1,17 @@ +-- Table: archive.mosip_credential_batch_job_execution_params + +-- DROP TABLE archive.mosip_credential_batch_job_execution_params; + +CREATE TABLE archive.mosip_credential_batch_job_execution_params ( + JOB_EXECUTION_ID BIGINT NOT NULL , + TYPE_CD VARCHAR(6) NOT NULL , + KEY_NAME VARCHAR(100) NOT NULL , + STRING_VAL VARCHAR(250) , + DATE_VAL TIMESTAMP DEFAULT NULL , + LONG_VAL BIGINT , + DOUBLE_VAL DOUBLE PRECISION , + IDENTIFYING CHAR(1) NOT NULL +) +WITH ( + OIDS = FALSE +); diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_job_instance.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_job_instance.sql new file mode 100644 index 00000000..7fce7c10 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_job_instance.sql @@ -0,0 +1,13 @@ +-- Table: archive.mosip_credential_batch_job_instance + +-- DROP TABLE archive.mosip_credential_batch_job_instance; + +CREATE TABLE archive.mosip_credential_batch_job_instance ( + JOB_INSTANCE_ID BIGINT PRIMARY KEY , + VERSION BIGINT, + JOB_NAME VARCHAR(100) NOT NULL , + JOB_KEY VARCHAR(2500) +) +WITH ( + OIDS = FALSE +); diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_step_execution.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_step_execution.sql new file mode 100644 index 00000000..810ed7f6 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_step_execution.sql @@ -0,0 +1,27 @@ +-- Table: archive.mosip_credential_batch_step_execution + +-- DROP TABLE archive.mosip_credential_batch_step_execution; + +CREATE TABLE archive.mosip_credential_batch_step_execution ( + STEP_EXECUTION_ID BIGINT PRIMARY KEY , + VERSION BIGINT NOT NULL, + STEP_NAME VARCHAR(100) NOT NULL, + JOB_EXECUTION_ID BIGINT NOT NULL, + START_TIME TIMESTAMP NOT NULL , + END_TIME TIMESTAMP DEFAULT NULL, + STATUS VARCHAR(10), + COMMIT_COUNT BIGINT , + READ_COUNT BIGINT , + FILTER_COUNT BIGINT , + WRITE_COUNT BIGINT , + READ_SKIP_COUNT BIGINT , + WRITE_SKIP_COUNT BIGINT , + PROCESS_SKIP_COUNT BIGINT , + ROLLBACK_COUNT BIGINT , + EXIT_CODE VARCHAR(20) , + EXIT_MESSAGE VARCHAR(2500) , + LAST_UPDATED TIMESTAMP +) +WITH ( + OIDS = FALSE +); diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_step_execution_context.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_step_execution_context.sql new file mode 100644 index 00000000..100f62ce --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-batch_step_execution_context.sql @@ -0,0 +1,15 @@ +-- Table: archive.mosip_credential_batch_step_execution_context + +-- DROP TABLE archive.mosip_credential_batch_step_execution_context; + +CREATE TABLE archive.mosip_credential_batch_step_execution_context +( + step_execution_id bigint NOT NULL, + short_context character varying(2500) COLLATE pg_catalog."default" NOT NULL, + serialized_context text COLLATE pg_catalog."default", + CONSTRAINT mosip_credential_batch_step_execution_context_pkey PRIMARY KEY (step_execution_id) + +) +WITH ( + OIDS = FALSE +); diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-credential-credential_transaction.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-credential_transaction.sql new file mode 100644 index 00000000..b09a39da --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-credential-credential_transaction.sql @@ -0,0 +1,69 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_credential +-- Table Name : archive.mosip_credential_credential_transaction +-- Purpose : Credential: The credential share is a functional service that interacts with the ID Repository and collects the user attributes for printing. +-- +-- Create By : Sadanandegowda DM +-- Created Date : Aug-2020 +-- +-- Modified Date Modified By Comments / Remarks +-- ------------------------------------------------------------------------------------------ +-- Jan-2021 Ram Bhatt Set is_deleted flag to not null and default false +-- Mar-2021 Ram Bhatt Reverting is_deleted not null changes +-- Apr-2021 Ram Bhatt status_comment added +-- ------------------------------------------------------------------------------------------ +-- object: archive.mosip_credential_credential_transaction | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_credential_credential_transaction CASCADE; +CREATE TABLE archive.mosip_credential_credential_transaction( + id character varying(36) NOT NULL, + credential_id character varying(36), + request character varying, + status_code character varying(32) NOT NULL, + datashareurl character varying(256), + issuancedate timestamp, + signature character varying, + trn_retry_count smallint, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + status_comment character varying(512), + CONSTRAINT pk_credtrn_id PRIMARY KEY (id) + +); + +CREATE INDEX cred_tran_NEW_status_cr_dtimes ON archive.mosip_credential_credential_transaction USING btree (cr_dtimes) WHERE status_code = 'NEW'; + +-- ddl-end -- +COMMENT ON TABLE archive.mosip_credential_credential_transaction IS 'Credential: The credential share is a functional service that interacts with the ID Repository and collects the user attributes for printing'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.id IS 'ID: Unique id generated by the system for each credentials generated'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.credential_id IS 'Credential Id: Credential id generated when distribute credential'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.request IS 'Request: Request json of credential request genrator'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.status_code IS 'Status Code: Contains status of request'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.datashareurl IS 'Datashare URL: Credential data url'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.issuancedate IS 'Issuance Date: Credential issue date'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.signature IS 'Signature: Signature of credential data'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.trn_retry_count IS 'Retry Count: Request retry count'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_credential_credential_transaction.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-esignet-consent_history.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-esignet-consent_history.sql new file mode 100644 index 00000000..f4b4d3e7 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-esignet-consent_history.sql @@ -0,0 +1,44 @@ +-- This Source Code Form is subject to the terms of the Mozilla Public +-- License, v. 2.0. If a copy of the MPL was not distributed with this +-- file, You can obtain one at https://mozilla.org/MPL/2.0/. +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_esignet +-- Table Name : archive.mosip_esignet_consent_history +-- Purpose : To store user consent details +-- +-- Create By : Hitesh C +-- Created Date : May-2023 +-- +-- Modified Date Modified By Comments / Remarks +-- ------------------------------------------------------------------------------------------ +-- ------------------------------------------------------------------------------------------ + +create table archive.mosip_esignet_consent_history ( + id UUID NOT NULL, + client_id VARCHAR NOT NULL, + psu_token VARCHAR NOT NULL, + claims VARCHAR NOT NULL, + authorization_scopes VARCHAR NOT NULL, + cr_dtimes TIMESTAMP DEFAULT NOW() NOT NULL, + expire_dtimes TIMESTAMP, + signature VARCHAR, + hash VARCHAR, + accepted_claims VARCHAR, + permitted_scopes VARCHAR, + PRIMARY KEY (id) +); +CREATE INDEX IF NOT EXISTS idx_mosip_esignet_consent_history_psu_client ON mosip_esignet_consent_history(psu_token, client_id); + +COMMENT ON TABLE archive.mosip_esignet_consent_history IS 'Contains user consent details'; + +COMMENT ON COLUMN archive.mosip_esignet_consent_history.id IS 'UUID : Unique id associated with each consent'; +COMMENT ON COLUMN archive.mosip_esignet_consent_history.client_id IS 'Client_id: associated with relying party'; +COMMENT ON COLUMN archive.mosip_esignet_consent_history.psu_token IS 'PSU token associated with user consent'; +COMMENT ON COLUMN archive.mosip_esignet_consent_history.claims IS 'Json of requested and user accepted claims'; +COMMENT ON COLUMN archive.mosip_esignet_consent_history.authorization_scopes IS 'Json string of requested authorization scope'; +COMMENT ON COLUMN archive.mosip_esignet_consent_history.cr_dtimes IS 'Consent creation date'; +COMMENT ON COLUMN archive.mosip_esignet_consent_history.expire_dtimes IS 'Expiration date'; +COMMENT ON COLUMN archive.mosip_esignet_consent_history.signature IS 'Signature of consent object '; +COMMENT ON COLUMN archive.mosip_esignet_consent_history.hash IS 'hash of consent object'; +COMMENT ON COLUMN archive.mosip_esignet_consent_history.accepted_claims IS 'Accepted Claims by the user'; +COMMENT ON COLUMN archive.mosip_esignet_consent_history.permitted_scopes IS 'Accepted Scopes by the user'; diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-ida-anonymous_profile.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-anonymous_profile.sql new file mode 100644 index 00000000..2c2863be --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-anonymous_profile.sql @@ -0,0 +1,45 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_ida +-- Table Name : mosip_ida_anonymous_profile +-- Purpose : anonymous_profile: Anonymous profiling information for reporting purpose. +-- +-- Create By : Loganathan Sekar +-- Created Date : 10-Sep-2021 +-- +-- Modified Date Modified By Comments / Remarks +-- ------------------------------------------------------------------------------------------ +-- Sep-2021 Loganathan Sekar Created anonymous_profile table +-- ------------------------------------------------------------------------------------------ + +-- object: archive.mosip_ida_anonymous_profile | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_ida_anonymous_profile CASCADE; +CREATE TABLE archive.mosip_ida_anonymous_profile( + id character varying(36) NOT NULL, + profile character varying NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_profile PRIMARY KEY (id) +); +-- ddl-end -- +COMMENT ON TABLE archive.mosip_ida_anonymous_profile IS 'anonymous_profile: Anonymous profiling information for reporting purpose.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_anonymous_profile.id IS 'Reference ID: System generated id for references in the system.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_anonymous_profile.profile IS 'Profile : Contains complete anonymous profile data generated by ID-Repository and stored in plain json text format.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_anonymous_profile.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_anonymous_profile.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_anonymous_profile.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_anonymous_profile.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_anonymous_profile.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_anonymous_profile.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-ida-auth_transaction.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-auth_transaction.sql new file mode 100644 index 00000000..ff701c3d --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-auth_transaction.sql @@ -0,0 +1,97 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_ida +-- Table Name : mosip_ida_auth_transaction +-- Purpose : Authentication Transaction : To track all authentication transactions steps / stages in the process flow. +-- +-- Create By : Nasir Khan / Sadanandegowda +-- Created Date : 15-Jul-2019 +-- +-- Modified Date Modified By Comments / Remarks +-- ------------------------------------------------------------------------------------------ +-- Sep-2020 Sadanandegowda DM Removed uin and uin_hash attribute and added token_id +-- Jan-2021 Ram Bhatt Set is_deleted flag to not null and default false +-- Feb-2021 Ram Bhatt Changed size of auth_type_code from 32 to 128 +-- Sep-2021 Ram Bhatt Added index to request_trn_id, request_dtimes, token_id columns +-- ------------------------------------------------------------------------------------------ + +-- object: archive.mosip_ida_auth_transaction | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_ida_auth_transaction CASCADE; +CREATE TABLE archive.mosip_ida_auth_transaction( + id character varying(36) NOT NULL, + request_dtimes timestamp NOT NULL, + response_dtimes timestamp NOT NULL, + request_trn_id character varying(64), + auth_type_code character varying(128) NOT NULL, + status_code character varying(36) NOT NULL, + status_comment character varying(1024), + lang_code character varying(3) NOT NULL, + ref_id_type character varying(36), + ref_id character varying(64), + token_id character varying(128) NOT NULL, + requested_entity_type character varying(64), + requested_entity_id character varying(36), + requested_entity_name character varying(128), + static_tkn_id character varying(64), + request_signature character varying, + response_signature character varying, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean NOT NULL DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_authtrn_id PRIMARY KEY (id) + +); +-- ddl-end -- +--index section starts---- +CREATE INDEX ind_reqtrnid_dtimes_tknid ON archive.mosip_ida_auth_transaction (request_trn_id, request_dtimes, token_id,cr_dtimes, auth_type_code); +--index section ends------ +COMMENT ON TABLE archive.mosip_ida_auth_transaction IS 'Authentication Transaction : To track all authentication transactions steps / stages in the process flow.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.id IS 'ID: This is unique transaction id assigned for each authentication transaction'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.request_dtimes IS 'Request Datetimestamp : Timestamp of Authentication request received from client system.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.response_dtimes IS 'Response Datetimestamp : Date timestamp of response sent back to client system for the authentication request. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.request_trn_id IS 'Request Transaction Id : Unique Authentication request transaction id assigned for each request received from client system.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.auth_type_code IS 'Authentication Type Code : Type of authentication for the specific transaction, for ex., OTP, BIO, DEMO, etc'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.status_code IS 'Status Code : Current Status code of the transaction in a process flow.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.status_comment IS 'Status Comment : Description for the status entered/updated by user or system assigned for the specific transaction.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.lang_code IS 'Language Code : For multilanguage implementation this attribute Refers master.language.code. The value of some of the attributes in current record is stored in this respective language. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.ref_id_type IS 'Reference Id Type: Type of reference id entered in reference id column for ex., USER, VIRTUALID, UIN, PREREG, etc.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.ref_id IS 'Reference Id: Reference ID for any cross reference purpose relevant for tracking, for ex., user id, uin, vid, prereg id, rid etc.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.token_id IS 'Token ID : Token ID generated in reference with UIN/VID'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.requested_entity_type IS 'Requested Entity Type: Type of entity through which the authentication request was initiated. It can from a partner, internal authenticaition, etc.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.requested_entity_id IS 'Requested Entity Id: ID of the entity through which the authentication request was initiated.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.requested_entity_name IS 'Requested Entity Name: Name of the entity through which the authentication request was initiated.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.static_tkn_id IS 'Static Token Id : This is a static token id assigned for each authentication request. Static token id is combination of TSPID + UIN generated for any TSP or Individuls and sent back in response. End user can use this id while authenticating themselves. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.request_signature IS 'Request Signature: Request body information stored with signed'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.response_signature IS 'Response Signature: Response body stored with signed'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_auth_transaction.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_job_execution.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_job_execution.sql new file mode 100644 index 00000000..4fd45e2b --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_job_execution.sql @@ -0,0 +1,20 @@ +-- Table: archive.mosip_ida_batch_job_execution + +-- DROP TABLE archive.mosip_ida_batch_job_execution; + +CREATE TABLE archive.mosip_ida_batch_job_execution ( + JOB_EXECUTION_ID BIGINT PRIMARY KEY , + VERSION BIGINT, + JOB_INSTANCE_ID BIGINT NOT NULL, + CREATE_TIME TIMESTAMP NOT NULL, + START_TIME TIMESTAMP DEFAULT NULL, + END_TIME TIMESTAMP DEFAULT NULL, + STATUS VARCHAR(10), + EXIT_CODE VARCHAR(20), + EXIT_MESSAGE VARCHAR(2500), + LAST_UPDATED TIMESTAMP, + JOB_CONFIGURATION_LOCATION VARCHAR(2500) NULL +) +WITH ( + OIDS = FALSE +); diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_job_execution_context.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_job_execution_context.sql new file mode 100644 index 00000000..49c75fff --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_job_execution_context.sql @@ -0,0 +1,14 @@ +-- Table: archive.mosip_ida_batch_job_execution_context + +-- DROP TABLE archive.mosip_ida_batch_job_execution_context; + +CREATE TABLE archive.mosip_ida_batch_job_execution_context +( + job_execution_id bigint NOT NULL, + short_context character varying(2500) COLLATE pg_catalog."default" NOT NULL, + serialized_context text COLLATE pg_catalog."default", + CONSTRAINT batch_job_execution_context_pkey PRIMARY KEY (job_execution_id) +) +WITH ( + OIDS = FALSE +); diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_job_execution_params.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_job_execution_params.sql new file mode 100644 index 00000000..8732698d --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_job_execution_params.sql @@ -0,0 +1,17 @@ +-- Table: mosip_ida_batch_job_execution_params + +-- DROP TABLE archive.mosip_ida_batch_job_execution_params; + +CREATE TABLE archive.mosip_ida_batch_job_execution_params ( + JOB_EXECUTION_ID BIGINT NOT NULL , + TYPE_CD VARCHAR(6) NOT NULL , + KEY_NAME VARCHAR(100) NOT NULL , + STRING_VAL VARCHAR(250) , + DATE_VAL TIMESTAMP DEFAULT NULL , + LONG_VAL BIGINT , + DOUBLE_VAL DOUBLE PRECISION , + IDENTIFYING CHAR(1) NOT NULL +) +WITH ( + OIDS = FALSE +); diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_job_instance.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_job_instance.sql new file mode 100644 index 00000000..15bab9aa --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_job_instance.sql @@ -0,0 +1,13 @@ +-- Table:mosip_ida_batch_job_instance + +-- DROP TABLE archive.mosip_ida_batch_job_instance; + +CREATE TABLE archive.mosip_ida_batch_job_instance ( + JOB_INSTANCE_ID BIGINT PRIMARY KEY , + VERSION BIGINT, + JOB_NAME VARCHAR(100) NOT NULL , + JOB_KEY VARCHAR(2500) +) +WITH ( + OIDS = FALSE +); diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_step_execution.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_step_execution.sql new file mode 100644 index 00000000..347e787b --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_step_execution.sql @@ -0,0 +1,27 @@ +-- Table: archive.mosip_ida_batch_step_execution + +-- DROP TABLE archive.mosip_ida_batch_step_execution; + +CREATE TABLE archive.mosip_ida_batch_step_execution ( + STEP_EXECUTION_ID BIGINT PRIMARY KEY , + VERSION BIGINT NOT NULL, + STEP_NAME VARCHAR(100) NOT NULL, + JOB_EXECUTION_ID BIGINT NOT NULL, + START_TIME TIMESTAMP NOT NULL , + END_TIME TIMESTAMP DEFAULT NULL, + STATUS VARCHAR(10), + COMMIT_COUNT BIGINT , + READ_COUNT BIGINT , + FILTER_COUNT BIGINT , + WRITE_COUNT BIGINT , + READ_SKIP_COUNT BIGINT , + WRITE_SKIP_COUNT BIGINT , + PROCESS_SKIP_COUNT BIGINT , + ROLLBACK_COUNT BIGINT , + EXIT_CODE VARCHAR(20) , + EXIT_MESSAGE VARCHAR(2500) , + LAST_UPDATED TIMESTAMP +) +WITH ( + OIDS = FALSE +); diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_step_execution_context.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_step_execution_context.sql new file mode 100644 index 00000000..9497f5b5 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-batch_step_execution_context.sql @@ -0,0 +1,15 @@ +-- Table: archive.mosip_ida_batch_step_execution_context + +-- DROP TABLE archive.mosip_ida_batch_step_execution_context; + +CREATE TABLE archive.mosip_ida_batch_step_execution_context +( + step_execution_id bigint NOT NULL, + short_context character varying(2500) COLLATE pg_catalog."default" NOT NULL, + serialized_context text COLLATE pg_catalog."default", + CONSTRAINT batch_step_execution_context_pkey PRIMARY KEY (step_execution_id) + +) +WITH ( + OIDS = FALSE +); diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-ida-credential_event_store.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-credential_event_store.sql new file mode 100644 index 00000000..ffd1c9cb --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-credential_event_store.sql @@ -0,0 +1,69 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_ida +-- Table Name : archive.mosip_ida_credential_event_store +-- Purpose : +-- +-- Create By : Sadanandegowda DM +-- Created Date : Jan-2021 +-- +-- Modified Date Modified By Comments / Remarks +-- ------------------------------------------------------------------------------------------ +-- Jan-2021 Ram Bhatt Set is_deleted flag to not null and default false +-- Mar-2021 Ram Bhatt Reverting is_deleted not null changes +-- Sep-2021 Ram Bhatt Added index to cr_dtimes column +-- ------------------------------------------------------------------------------------------ + +-- object: archive.mosip_ida_credential_event_store | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_ida_credential_event_store CASCADE; +CREATE TABLE archive.mosip_ida_credential_event_store( + event_id character varying(36) NOT NULL, + event_topic character varying(256) NOT NULL, + credential_transaction_id character varying(36) NOT NULL, + publisher character varying(128), + published_on_dtimes timestamp, + event_object character varying, + status_code character varying(36), + retry_count smallint, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_ces_id PRIMARY KEY (event_id) + +); +-- ddl-end -- +--index section starts---- +CREATE INDEX ind_ces_id ON archive.mosip_ida_credential_event_store (cr_dtimes); +--index section ends------ +COMMENT ON TABLE archive.mosip_ida_credential_event_store IS 'Credential Event Store: Store all credential request in IDA and their status, Retry request incase of failure'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.event_id IS 'Event ID: Event id of the credential request'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.event_topic IS 'Event Topic: Topic of the credential request where message is requested through websub'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.credential_transaction_id IS 'Credential transaction id where credential request details are stored'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.publisher IS 'Pusblisher of the messages'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.published_on_dtimes IS 'Date and time of the message published'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.event_object IS 'Credential event object details'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.status_code IS 'Status of the envent ex: NEW, STORED, FAILED, FAILED_WITH_MAX_RETRIES'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.retry_count IS 'Retry count of the credential request event incase of failure'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_credential_event_store.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-ida-otp_transaction.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-otp_transaction.sql new file mode 100644 index 00000000..c8bbb4da --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-ida-otp_transaction.sql @@ -0,0 +1,66 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_ida +-- Table Name : mosip_ida_otp_transaction +-- Purpose : OTP Transaction: All OTP related data and validation details are maintained here for ID Authentication. +-- +-- Create By : Sadanandegowda DM +-- Created Date : Sep-2020 +-- +-- Modified Date Modified By Comments / Remarks +-- ------------------------------------------------------------------------------------------ + +-- ------------------------------------------------------------------------------------------ +-- object: archive.mosip_ida_otp_transaction | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_ida_otp_transaction CASCADE; +CREATE TABLE archive.mosip_ida_otp_transaction( + id character varying(36) NOT NULL, + ref_id character varying(64) NOT NULL, + otp_hash character varying(512) NOT NULL, + generated_dtimes timestamp, + expiry_dtimes timestamp, + validation_retry_count smallint, + status_code character varying(36), + lang_code character varying(3), + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_otpt_id PRIMARY KEY (id) + +); +-- ddl-end -- +--index section starts---- +CREATE INDEX ind_otphsh ON archive.mosip_ida_otp_transaction (otp_hash,status_code); +--index section ends------ +COMMENT ON TABLE archive.mosip_ida_otp_transaction IS 'OTP Transaction: All OTP related data and validation details are maintained here for ID Authentication module.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.id IS 'ID: Key alias id is a unique identifier (UUID) used as an alias of the encryption key stored in keystore like HSM (hardware security module).'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.ref_id IS 'Reference ID: Reference ID is a reference information received from OTP requester which can be used while validating the OTP. AM: please give examples of ref_id'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.otp_hash IS 'OTP Hash: Hash of id, ref_id and otp which is generated based on the configuration setup and sent to the requester application / module.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.generated_dtimes IS 'Generated Date Time: Date and Time when the OTP was generated'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.expiry_dtimes IS 'Expiry Date Time: Date Time when the OTP will be expired'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.validation_retry_count IS 'Validation Retry Count: Validation retry counts of this OTP request. If the validation retry crosses the threshold limit, then the OTP will be de-activated.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.status_code IS 'Status Code: Status of the OTP whether it is active or expired. AM: please enumerate the status types. They are only a few, not infinite'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.lang_code IS 'Language Code : For multilanguage implementation this attribute Refers master.language.code. The value of some of the attributes in current record is stored in this respective language.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_ida_otp_transaction.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-idrepo-anonymous_profile.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-idrepo-anonymous_profile.sql new file mode 100644 index 00000000..c404d8df --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-idrepo-anonymous_profile.sql @@ -0,0 +1,45 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_idrepo +-- Table Name : archive.mosip_idrepo_anonymous_profile +-- Purpose : anonymous_profile: Anonymous profiling information for reporting purpose. +-- +-- Create By : Manoj SP +-- Created Date : 10-Sep-2021 +-- +-- Modified Date Modified By Comments / Remarks +-- ------------------------------------------------------------------------------------------ +-- Sep-2021 Manoj SP Created anonymous_profile table +-- ------------------------------------------------------------------------------------------ + +-- object: archive.mosip_idrepo_anonymous_profile | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_idrepo_anonymous_profile CASCADE; +CREATE TABLE archive.mosip_idrepo_anonymous_profile( + id character varying(36) NOT NULL, + profile character varying NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_profile_idrepo PRIMARY KEY (id) +); +-- ddl-end -- +COMMENT ON TABLE archive.mosip_idrepo_anonymous_profile IS 'anonymous_profile: Anonymous profiling information for reporting purpose.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_idrepo_anonymous_profile.id IS 'Reference ID: System generated id for references in the system.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_idrepo_anonymous_profile.profile IS 'Profile : Contains complete anonymous profile data generated by ID-Repository and stored in plain json text format.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_idrepo_anonymous_profile.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_idrepo_anonymous_profile.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_idrepo_anonymous_profile.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_idrepo_anonymous_profile.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_idrepo_anonymous_profile.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_idrepo_anonymous_profile.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-idrepo-credential_request_status.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-idrepo-credential_request_status.sql new file mode 100644 index 00000000..63abd7cd --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-idrepo-credential_request_status.sql @@ -0,0 +1,34 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_repo +-- Table Name : archive.mosip_idrepo_credential_request_status +-- Purpose : Credential Request Status: +-- +-- Create By : Ram Bhatt +-- Created Date : May-2021 +-- +-- Modified Date Modified By Comments / Remarks +-- ------------------------------------------------------------------------------------------ +-- +-- ------------------------------------------------------------------------------------------ + +-- object: archive.mosip_idrepo_credential_request_status | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_idrepo_credential_request_status CASCADE; +CREATE TABLE archive.mosip_idrepo_credential_request_status ( + individual_id character varying(500) NOT NULL, + individual_id_hash character varying(128) NOT NULL, + partner_id character varying(36) NOT NULL, + request_id character varying(36), + token_id character varying(128), + status character varying(36) NOT NULL, + id_transaction_limit numeric, + id_expiry_timestamp timestamp, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted bool DEFAULT false, + del_dtimes timestamp, + CONSTRAINT credential_request_status_pk PRIMARY KEY (individual_id_hash,partner_id) + +); +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-idrepo-uin_draft.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-idrepo-uin_draft.sql new file mode 100644 index 00000000..c14838a8 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-idrepo-uin_draft.sql @@ -0,0 +1,33 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_repo +-- Table Name : archive.mosip_idrepo_uin_draft +-- Purpose : UIN Hash Salt: +-- +-- Create By : Ram Bhatt +-- Created Date : Jul-2021 +-- +-- Modified Date Modified By Comments / Remarks +-- ------------------------------------------------------------------------------------------ +-- Sep-2021 Manoj SP Removed Anonymous Profile column +-- ------------------------------------------------------------------------------------------ + +-- object: archive.mosip_idrepo_uin_draft | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_idrepo_uin_draft CASCADE; +CREATE TABLE archive.mosip_idrepo_uin_draft( + reg_id character varying (39) NOT NULL, + uin character varying (500) NOT NULL, + uin_hash character varying (128) NOT NULL, + uin_data bytea, + uin_data_hash character varying (64), + status_code character varying (32) NOT NULL, + cr_by character varying (256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying (256), + upd_dtimes timestamp, + is_deleted bool DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_uindft_id PRIMARY KEY (reg_id), + CONSTRAINT unq_uin UNIQUE (uin), + CONSTRAINT unq_uinhsh UNIQUE (uin_hash) +); +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-kernel-otp_transaction.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-kernel-otp_transaction.sql new file mode 100644 index 00000000..fe2a34e1 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-kernel-otp_transaction.sql @@ -0,0 +1,56 @@ + + +-- object: archive.mosip_kernel_otp_transaction | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_kernel_otp_transaction CASCADE; +CREATE TABLE archive.mosip_kernel_otp_transaction( + id character varying(64) NOT NULL, + ref_id character varying(64), + ref_id_type character varying(64), + otp character varying(8), + generated_dtimes timestamp, + expiry_dtimes timestamp, + validation_retry_count smallint, + status_code character varying(64), + lang_code character varying(3), + cr_by character varying(256), + cr_dtimes timestamp, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_otptrn_id PRIMARY KEY (id) + +); +-- ddl-end -- +COMMENT ON TABLE archive.mosip_kernel_otp_transaction IS 'OTP Transaction: All OTP related data and validation details are maintained here. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.id IS 'ID: Unique transaction id for each otp transaction request'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.ref_id IS 'Reference ID: Reference ID is a reference information received from OTP requester which can be used while validating the OTP. AM: please give examples of ref_id'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.ref_id_type IS 'Reference ID Type: Type of information in Reference ID field, used to reference this OTP request. AM: i guess only email & ph are the types. Please specify'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.otp IS 'OTP: One Time Pin which is generated based on the configuration setup and sent to the requester application / module.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.generated_dtimes IS 'Generated Date Time: Date and Time when the OTP was generated'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.expiry_dtimes IS 'Expiry Date Time: Date Time when the OTP will be expired'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.validation_retry_count IS 'Validation Retry Count: Validation retry counts of this OTP request. If the validation retry crosses the threshold limit, then the OTP will be de-activated.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.status_code IS 'Status Code: Status of the OTP whether it is active or expired. AM: please enumerate the status types. They are only a few, not infinite'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.lang_code IS 'Language Code : For multilanguage implementation this attribute Refers master.language.code. The value of some of the attributes in current record is stored in this respective language. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_kernel_otp_transaction.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-master-bulkupload_transaction.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-master-bulkupload_transaction.sql new file mode 100644 index 00000000..7d8149e0 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-master-bulkupload_transaction.sql @@ -0,0 +1,61 @@ + +-- object: archive.mosip_master_bulkupload_transaction | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_master_bulkupload_transaction CASCADE; +CREATE TABLE archive.mosip_master_bulkupload_transaction( + id character varying(36) NOT NULL, + entity_name character varying(64) NOT NULL, + upload_operation character varying(64) NOT NULL, + status_code character varying(36) NOT NULL, + record_count integer, + uploaded_by character varying(256) NOT NULL, + upload_category character varying(36), + uploaded_dtimes timestamp NOT NULL, + upload_description character varying, + lang_code character varying(3) NOT NULL, + is_active boolean NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_butrn_id PRIMARY KEY (id) + +); +-- ddl-end -- +COMMENT ON TABLE archive.mosip_master_bulkupload_transaction IS 'Bulk Upload Transaction: This transaction table to store all bulk upload transactions, This includes uploading master table data as well as packets uploads to the registration processor.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.id IS 'ID: Unigue ID is assign to bulk data upload transaction. Each transaction will be identifieds by this transaction id.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.entity_name IS 'Entity Name: Name of an entity for which data is beeing uploaded, This can be master data table name or packet in case of packet upload.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.upload_operation IS 'Upload Operation: Operation of the bulk upload example operations can be insert, update, delete and packet-upload.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.status_code IS 'Status Code: Status of the bulk upload transactions. For example... in-progress, success and failed transaction.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.record_count IS 'Record Count: Number of records and packets has been uploaded in a transaction.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.uploaded_by IS 'Uploaded By: The user detail of the person who is uploading the packets or master data.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.upload_category IS 'Upload Category: Upload category will be Master data csv or Packet'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.uploaded_dtimes IS 'Uploaded Date and Time: Date and time of the master data and packets are uploaded'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.upload_description IS 'Upload Description: Bulk data upload description, This will have all details about the transaction including upload failure or success messages.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.lang_code IS 'Language Code : For multilanguage implementation this attribute Refers master.language.code. The value of some of the attributes in current record is stored in this respective language.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.is_active IS 'IS_Active : Flag to mark whether the record/device is Active or In-active'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_bulkupload_transaction.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-master-device_master_h.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-master-device_master_h.sql new file mode 100644 index 00000000..a675cc5b --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-master-device_master_h.sql @@ -0,0 +1,65 @@ + + +-- object: archive.mosip_master_device_master_h | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_master_device_master_h CASCADE; +CREATE TABLE archive.mosip_master_device_master_h( + id character varying(36) NOT NULL, + name character varying(64) NOT NULL, + mac_address character varying(64) NOT NULL, + serial_num character varying(64) NOT NULL, + ip_address character varying(17), + validity_end_dtimes timestamp, + dspec_id character varying(36) NOT NULL, + zone_code character varying(36) NOT NULL, + regcntr_id character varying(10), + lang_code character varying(3) , + is_active boolean NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + eff_dtimes timestamp NOT NULL, + CONSTRAINT pk_devicem_h_id PRIMARY KEY (id,eff_dtimes) + +); +-- ddl-end -- +COMMENT ON TABLE archive.mosip_master_device_master_h IS 'Device Master History : This to track changes to master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ), Effective DateTimestamp is used for identifying latest or point in time information. Refer master.device_master table description for details. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.id IS 'Device ID : Unique ID generated / assigned for device'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.name IS 'Name : Device name'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.mac_address IS 'Mac Address: Mac address of the device'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.serial_num IS 'Serial Number: Serial number of the device'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.ip_address IS 'IP Address: IP address of the device'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.validity_end_dtimes IS 'Validity End Datetime: Device validity expiry date'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.dspec_id IS 'Device Specification ID : Device specification id refers to master.device_spec.id'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.zone_code IS 'Zone Code : Unique zone code generated or entered by admin while creating zones, It is referred to master.zone.code. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.regcntr_id IS 'Registration Center ID : registration center id refers to master.registration_center.id'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.lang_code IS 'Language Code : For multilanguage implementation this attribute Refers master.language.code. The value of some of the attributes in current record is stored in this respective language. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.is_active IS 'IS_Active : Flag to mark whether the record is Active or In-active'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_device_master_h.eff_dtimes IS 'Effective Date Timestamp : This to track master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ). The current record is effective from this date-time. '; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-master-machine_master_h.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-master-machine_master_h.sql new file mode 100644 index 00000000..4b41c0ef --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-master-machine_master_h.sql @@ -0,0 +1,48 @@ +CREATE TABLE archive.mosip_master_machine_master_h( + id character varying(10) NOT NULL, + name character varying(64) NOT NULL, + mac_address character varying(64), + serial_num character varying(64), + ip_address character varying(17), + validity_end_dtimes timestamp, + mspec_id character varying(36) NOT NULL, + public_key character varying(1024), + key_index character varying(128), + sign_public_key character varying(1024), + sign_key_index character varying(128), + zone_code character varying(36) NOT NULL, + regcntr_id character varying(10), + lang_code character varying(3) , + is_active boolean NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + eff_dtimes timestamp NOT NULL, + CONSTRAINT pk_machm_h_id PRIMARY KEY (id,eff_dtimes) +); +COMMENT ON TABLE archive.mosip_master_machine_master_h IS 'Machine Master History : This to track changes to master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ), Effective DateTimestamp is used for identifying latest or point in time information. Refer master.machine_master table description for details. '; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.id IS 'Machine ID : Unique ID generated / assigned for machine'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.name IS 'Name : Machine name'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.mac_address IS 'Mac Address: Mac address of the machine'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.serial_num IS 'Serial Number: Serial number of the machine'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.ip_address IS 'IP Address: IP address of the machine'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.validity_end_dtimes IS 'Validity End Datetime: Machine validity expiry date'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.mspec_id IS 'Machine Specification ID : Machince specification id refers to master.machine_spec.id'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.public_key IS 'Public Key: Public key of the machine, This will be Machine Identification TPM Endorsement key'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.key_index IS 'Key Index: Fingerprint[Unique Hash ] for the TPM public key'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.sign_public_key IS 'Signed Public Key: Field for signature verification publicKey'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.sign_key_index IS 'Signed Key Index: Field for signature verification public key fingerprint'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.zone_code IS 'Zone Code : Unique zone code generated or entered by admin while creating zones, It is referred to master.zone.code. '; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.regcntr_id IS 'Registration Center ID : registration center id refers to master.registration_center.id'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.lang_code IS 'Language Code : For multilanguage implementation this attribute Refers master.language.code. The value of some of the attributes in current record is stored in this respective language. '; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.is_active IS 'IS_Active : Flag to mark whether the record is Active or In-active'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.cr_by IS 'Created By : ID or name of the user who create / insert record'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +COMMENT ON COLUMN archive.mosip_master_machine_master_h.eff_dtimes IS 'Effective Date Timestamp : This to track master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ). The current record is effective from this date-time. '; diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-master-registration_center_h.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-master-registration_center_h.sql new file mode 100644 index 00000000..28774a9f --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-master-registration_center_h.sql @@ -0,0 +1,101 @@ + + +-- object: archive.mosip_master_registration_center_h | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_master_registration_center_h CASCADE; +CREATE TABLE archive.mosip_master_registration_center_h( + id character varying(10) NOT NULL, + name character varying(128) NOT NULL, + cntrtyp_code character varying(36), + addr_line1 character varying(256), + addr_line2 character varying(256), + addr_line3 character varying(256), + latitude character varying(32), + longitude character varying(32), + location_code character varying(36) NOT NULL, + contact_phone character varying(16), + contact_person character varying(128), + number_of_kiosks smallint, + working_hours character varying(32), + per_kiosk_process_time time, + center_start_time time, + center_end_time time, + lunch_start_time time, + lunch_end_time time, + time_zone character varying(64), + holiday_loc_code character varying(36), + zone_code character varying(36) NOT NULL, + lang_code character varying(3) NOT NULL, + is_active boolean NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE , + del_dtimes timestamp, + eff_dtimes timestamp NOT NULL, + CONSTRAINT pk_regcntr_h_code PRIMARY KEY (id,lang_code,eff_dtimes) + +); +-- ddl-end -- +COMMENT ON TABLE archive.mosip_master_registration_center_h IS 'Registration Center History : This to track changes to master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ), Effective DateTimestamp is used for identifying latest or point in time information. Refer master.registration_center table description for details.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.id IS 'Registration Center ID : Unique ID generated / assigned for a registration center'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.name IS 'Name : Registration center name'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.cntrtyp_code IS 'Center Type Code : different types of registration centers. Refers master.reg_center_type.code'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.addr_line1 IS 'Registration Center Address Line1 : for ex. Number, street name, locality, etc.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.addr_line2 IS 'Registration Center Address Line2 : for ex. Number, street name, locality, etc.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.addr_line3 IS 'Registration Center Address Line3 : for ex. locality, landmark, area etc.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.latitude IS 'Latitude: Latitude of the registration center location as per GPS standards / format'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.longitude IS 'Longitude: Longitude of the registration center location as per GPS standards / format'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.location_code IS 'Location Code: Location code of the registration center located. Refers to master.location.code'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.contact_phone IS 'Contact Phone : Phone number of of the person to be contacted for any additional details.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.contact_person IS 'Contact Person : Name of the person to be contacted for any additional details.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.number_of_kiosks IS 'Number of Kiosks: Total number of kiosks available at a registration center'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.working_hours IS 'Working hours: Working hours of a registration center (8.00 AM - 6.00 PM) '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.per_kiosk_process_time IS 'Process Time Per Registration: Average process time for registration process per kiosk'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.center_start_time IS 'Center Start Time : registration center working opening hour / start time.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.center_end_time IS 'Center End Time : registration center working closing hour / end time.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.lunch_start_time IS 'Lunch Start Time: Registration centers lunch break start time'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.lunch_end_time IS 'Lunch End Time: Registration centers lunch break end time'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.time_zone IS 'Time Zone: Registration centers local timezone GMT, PST, IST'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.holiday_loc_code IS 'Holiday Location Code: Location code at which holidays are defined'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.zone_code IS 'Zone Code : Unique zone code generated or entered by admin while creating zones, It is referred to master.zone.code. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.lang_code IS 'Language Code : For multilanguage implementation this attribute Refers master.language.code. The value of some of the attributes in current record is stored in this respective language. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.is_active IS 'IS_Active : Flag to mark whether the record is Active or In-active'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_registration_center_h.eff_dtimes IS 'Effective Date Timestamp : This to track master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ). The current record is effective from this date-time. '; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-master-user_detail_h.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-master-user_detail_h.sql new file mode 100644 index 00000000..7d3f161a --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-master-user_detail_h.sql @@ -0,0 +1,56 @@ + + +-- object: archive.mosip_master_user_detail_h | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_master_user_detail_h CASCADE; +CREATE TABLE archive.mosip_master_user_detail_h( + id character varying(256) NOT NULL, + name character varying(64) NOT NULL, + status_code character varying(36), + regcntr_id character varying(10), + lang_code character varying(3), + last_login_dtimes timestamp, + last_login_method character varying(64), + is_active boolean NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + eff_dtimes timestamp NOT NULL, + CONSTRAINT pk_usrdtl_h_id PRIMARY KEY (id,eff_dtimes) + +); +-- ddl-end -- +COMMENT ON TABLE archive.mosip_master_user_detail_h IS 'User Detail History : This to track changes to master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ), Effective DateTimestamp is used for identifying latest or point in time information. Refer master.user_detail table description for details.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.id IS 'User ID : Unique ID generated / assigned for a user'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.name IS 'Name : User name'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.status_code IS 'Status Code: User status. Refers to master.status_master.code'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.regcntr_id IS 'Registration Center ID : registration center id refers to master.registration_center.id'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.lang_code IS 'Language Code : For multilanguage implementation this attribute Refers master.language.code. The value of some of the attributes in current record is stored in this respective language. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.last_login_dtimes IS 'Last Login Datetime: Date and time of the last login by the user'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.last_login_method IS 'Last Login Method: Previous login method in which the user logged into the system'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.is_active IS 'IS_Active : Flag to mark whether the record is Active or In-active'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_user_detail_h.eff_dtimes IS 'Effective Date Timestamp : This to track master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ). The current record is effective from this date-time. '; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-master-zone_user_h.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-master-zone_user_h.sql new file mode 100644 index 00000000..052275b5 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-master-zone_user_h.sql @@ -0,0 +1,44 @@ + + +-- object: archive.mosip_master_zone_user_h | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_master_zone_user_h CASCADE; +CREATE TABLE archive.mosip_master_zone_user_h( + zone_code character varying(36) NOT NULL, + usr_id character varying(256) NOT NULL, + lang_code character varying(3), + is_active boolean NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + eff_dtimes timestamp NOT NULL, + CONSTRAINT pk_zoneuserh PRIMARY KEY (zone_code,usr_id,eff_dtimes) + +); +-- ddl-end -- +COMMENT ON TABLE archive.mosip_master_zone_user_h IS 'Zone User History : This to track changes to master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ), Effective DateTimestamp is used for identifying latest or point in time information. Refer master.zone_user table description for details.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_zone_user_h.zone_code IS 'Code : Unique zone code generated or entered by admin while creating zones. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_zone_user_h.usr_id IS 'User ID : ID of the user which is mapped to zone, This user will have defined roles based on which user is mapped to zones.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_zone_user_h.lang_code IS 'Language Code : For multilanguage implementation this attribute Refers master.language.code. The value of some of the attributes in current record is stored in this respective language. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_zone_user_h.is_active IS 'IS_Active : Flag to mark whether the record is Active or In-active'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_zone_user_h.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_zone_user_h.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_zone_user_h.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_zone_user_h.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_zone_user_h.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_zone_user_h.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_master_zone_user_h.eff_dtimes IS 'Effective Date Timestamp : This to track master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ). The current record is effective from this date-time. '; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-pms-auth_policy_h.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-pms-auth_policy_h.sql new file mode 100644 index 00000000..afe09ee6 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-pms-auth_policy_h.sql @@ -0,0 +1,81 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_pms +-- Table Name : archive.mosip_pms_auth_policy_h +-- Purpose : Authentication Policy History: This to track changes to master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ), Effective DateTimestamp is used for identifying latest or point in time information. Refer pmp.auth_policy table description for details. +-- +-- Create By : Sadanandegowda DM +-- Created Date : Aug-2020 +-- +-- Modified Date Modified By Comments / Remarks +-- ------------------------------------------------------------------------------------------ +-- Aug-2020 Sadanndegowda Added policy_type, version, schema and validity +-- Aug-2020 Sadanndegowda Updated Schema name +-- Jan-2021 Ram Bhatt Set is_deleted flag to not null and default false +-- Mar-2021 Ram Bhatt Reverting is_deleted flag not null changes for 1.1.5 +-- ------------------------------------------------------------------------------------------ + +-- object: archive.mosip_pms_auth_policy_h | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_pms_auth_policy_h CASCADE; +CREATE TABLE archive.mosip_pms_auth_policy_h( + id character varying(36) NOT NULL, + eff_dtimes timestamp NOT NULL, + policy_group_id character varying(36), + name character varying(128) NOT NULL, + descr character varying(256) NOT NULL, + policy_file_id character varying(5120) NOT NULL, + policy_type character varying(36) NOT NULL, + version character varying(8) NOT NULL, + policy_schema character varying(5120), + valid_from_date timestamp NOT NULL, + valid_to_date timestamp NOT NULL, + is_active boolean NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_apolh PRIMARY KEY (id,eff_dtimes), + CONSTRAINT uk_apolh UNIQUE (eff_dtimes,policy_group_id,name) + +); +-- ddl-end -- +COMMENT ON TABLE archive.mosip_pms_auth_policy_h IS 'Authentication Policy History: This to track changes to master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ), Effective DateTimestamp is used for identifying latest or point in time information. Refer pmp.auth_policy table description for details. +'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.id IS 'ID: A unique identity '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.eff_dtimes IS 'Effective Date Timestamp : This to track master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ). The current record is effective from this date-time. '; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.policy_group_id IS 'Polocy Group ID: Id of the policy group to which this policy belongs.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.name IS 'Name: Name of the policy'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.descr IS 'Description: Description of the policy'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.policy_file_id IS 'Policy File ID: Policy are defined by Policy / Partner manager are stored in file system or key based storages like CEPH. The policy file details (location / id / key) is stored here.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.policy_type IS 'Policy Type: Type of the policy for example authentication, Data_Share, Credential_Issuance...etc.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.version IS 'Policy Version : Version number of the policy, Version to be upgraded based on changes to the policy'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.policy_schema IS 'Policy Schema: Policy schema, schema is populated based on policy type'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.valid_from_date IS 'Policy Valid From Date: Date and time from when the policy is valid'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.valid_to_date IS 'Valid To Date: Date and time till when the policy is valid'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.is_active IS 'IS_Active : Flag to mark whether the record is Active or In-active'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.cr_by IS 'Created By : ID or name of the user who create / insert record'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_pms_auth_policy_h.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-pms-partner_h.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-pms-partner_h.sql new file mode 100644 index 00000000..ca15094b --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-pms-partner_h.sql @@ -0,0 +1,45 @@ + +CREATE TABLE archive.mosip_pms_partner_h( + id character varying(36) NOT NULL, + eff_dtimes timestamp NOT NULL, + policy_group_id character varying(36), + name character varying(128) NOT NULL, + address character varying(2000), + contact_no character varying(16), + email_id character varying(254), + certificate_alias character varying(128), + user_id character varying(256) NOT NULL, + partner_type_code character varying(36) NOT NULL, + approval_status character varying(36) NOT NULL, + is_active boolean NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + lang_code character varying(36), + logo_url character varying(256), + addl_info character varying, + CONSTRAINT pk_parth PRIMARY KEY (id,eff_dtimes) +); + +COMMENT ON TABLE archive.mosip_pms_partner_h IS 'Partner History: This to track changes to master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ), Effective DateTimestamp is used for identifying latest or point in time information. Refer pmp.auth_policy table description for details. '; +COMMENT ON COLUMN archive.mosip_pms_partner_h.id IS 'Partner ID : Unique ID generated / assigned for partner'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.eff_dtimes IS 'Effective Date Timestamp : This to track master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ). The current record is effective from this date-time. '; +COMMENT ON COLUMN archive.mosip_pms_partner_h.policy_group_id IS 'Policy Group ID: Policy group to which the partner registers for to avail the auth services.'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.name IS 'Name: Name of the Partner.'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.address IS 'Address: Address of the partner organization'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.contact_no IS 'Contact Number: Contact number of the partner organization or the contact person'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.email_id IS 'Email ID: Email ID of the MISP organization''s contact person'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.certificate_alias IS 'Certificate Alias: Certificate alias provided by the partner to MOSIP to use its authentication request data.'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.user_id IS 'Partner Admin: When a partner registers themselves to avail auth services, a user id is created for them to login to partner management portal to perform few operational activities. Currently only one user is created per partner.'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.partner_type_code IS 'Partner Type Code: Partner type code for different type of partners... Referenced from pmp.partner_type table'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.approval_status IS 'Approval Status: Status of the partner. Status gives the partner status is pending, approved or rejected by partner admin'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.is_active IS 'IS_Active : Flag to mark whether the record is Active or In-active'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.cr_by IS 'Created By : ID or name of the user who create / insert record'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +COMMENT ON COLUMN archive.mosip_pms_partner_h.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-pms-secure_biometric_interface_h.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-pms-secure_biometric_interface_h.sql new file mode 100644 index 00000000..b7133732 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-pms-secure_biometric_interface_h.sql @@ -0,0 +1,37 @@ +-- TODO: check if provider_id non null constraint is required. +CREATE TABLE archive.mosip_pms_secure_biometric_interface_h( + id character varying(36) NOT NULL, + sw_binary_hash bytea NOT NULL, + sw_version character varying(64) NOT NULL, + sw_cr_dtimes timestamp, + sw_expiry_dtimes timestamp, + approval_status character varying(36) NOT NULL, + is_active boolean NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + eff_dtimes timestamp NOT NULL, + -- provider_id character varying(36) NOT NULL, + provider_id character varying(36), + partner_org_name character varying(128), + CONSTRAINT pk_mdsh_id PRIMARY KEY (id,eff_dtimes) +); + +COMMENT ON TABLE archive.mosip_pms_secure_biometric_interface_h IS 'MOSIP Secure Biometric Interface History : History of changes of any MOSIP secure biometric interface will be stored in history table to track any chnages for future validations.'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.id IS 'ID: Unigue service ID, Service ID is geerated by the MOSIP system'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.sw_binary_hash IS 'Software Binary Hash : Its is a software binary stored in MOSIP system for the devices'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.sw_version IS 'Software Version : Version of the stored software'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.sw_cr_dtimes IS 'Software Created Date Time: Date and Time on which this software is created'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.sw_expiry_dtimes IS 'Software Expiry Date Time: Expiry date and time of the device software'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.approval_status IS 'Approval Status'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.is_active IS 'IS_Active : Flag to mark whether the record/device is Active or In-active'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.cr_by IS 'Created By : ID or name of the user who create / insert record'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +COMMENT ON COLUMN archive.mosip_pms_secure_biometric_interface_h.eff_dtimes IS 'Effective Date Timestamp : This to track master record whenever there is an INSERT/UPDATE/DELETE ( soft delete ). The current record is effective from this date-time.'; diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-prereg-otp_transaction.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-prereg-otp_transaction.sql new file mode 100644 index 00000000..18d16edc --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-prereg-otp_transaction.sql @@ -0,0 +1,35 @@ +-- This is used to save the OTP for the user whenever user requests for one using the email id / phone number to log into the application. + +CREATE TABLE archive.mosip_prereg_otp_transaction( + id character varying(36) NOT NULL, + ref_id character varying(64) NOT NULL, + otp_hash character varying(512) NOT NULL, + generated_dtimes timestamp, + expiry_dtimes timestamp, + validation_retry_count smallint, + status_code character varying(36), + lang_code character varying(3), + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean, + del_dtimes timestamp, + CONSTRAINT pk_otptrans_id PRIMARY KEY (id) +); + +COMMENT ON TABLE archive.mosip_prereg_otp_transaction IS 'All OTP related data and validation details are maintained here for Pre Registration module.'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.id IS 'OTP id is a unique identifier (UUID) used as an unique key to identify the OTP transaction'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.ref_id IS 'Reference ID is a reference information received from OTP requester which can be used while validating the OTP. AM: please give examples of ref_id'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.otp_hash IS 'Hash of id, ref_id and otp which is generated based on the configuration setup and sent to the requester application / module.'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.generated_dtimes IS 'Date and Time when the OTP was generated'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.expiry_dtimes IS 'Date Time when the OTP will be expired'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.validation_retry_count IS 'Validation retry counts of this OTP request. If the validation retry crosses the threshold limit, then the OTP will be de-activated.'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.status_code IS 'Current status of the transaction. Refers to code field of master.status_list table.'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.lang_code IS 'For multilanguage implementation this attribute Refers master.language.code. The value of some of the attributes in current record is stored in this respective language.'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.cr_by IS 'ID or name of the user who create / insert record.'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.cr_dtimes IS 'Date and Timestamp when the record is created/inserted'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.upd_by IS 'ID or name of the user who update the record with new values'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.upd_dtimes IS 'Date and Timestamp when any of the fields in the record is updated with new values.'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.is_deleted IS 'Flag to mark whether the record is Soft deleted.'; +COMMENT ON COLUMN archive.mosip_prereg_otp_transaction.del_dtimes IS 'Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-abis_request.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-abis_request.sql new file mode 100644 index 00000000..53d613a9 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-abis_request.sql @@ -0,0 +1,67 @@ + + +-- object: archive.mosip_regprc_abis_request | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_regprc_abis_request CASCADE; +CREATE TABLE archive.mosip_regprc_abis_request( + id character varying(36) NOT NULL, + req_batch_id character varying(36) NOT NULL, + abis_app_code character varying(36) NOT NULL, + request_type character varying(64) NOT NULL, + request_dtimes timestamp NOT NULL, + bio_ref_id character varying(36), + ref_regtrn_id character varying(36), + req_text bytea, + status_code character varying(36) NOT NULL, + status_comment character varying(256), + lang_code character varying(3) NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_abisreq PRIMARY KEY (id), + CONSTRAINT uk_abisreq_ref UNIQUE (req_batch_id,abis_app_code) + +); +-- ddl-end -- +-- index creation starts-- +CREATE INDEX IF NOT EXISTS idx_user_detail_cntr_id ON archive.mosip_regprc_abis_request USING btree (bio_ref_id); +CREATE INDEX IF NOT EXISTS idx_abis_req_regtrn_id ON archive.mosip_regprc_abis_request USING btree (ref_regtrn_id); +-- index creation ends-- +COMMENT ON TABLE archive.mosip_regprc_abis_request IS 'ABIS Request: Stores all the requests that were sent to ABIS systems'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.id IS 'Request ID: System generated id, used to track all the ABIS request sent to ABIS applications.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.req_batch_id IS 'Request Batch ID: ABIS Request Batch ID to track all the requests that was sent to different ABIS systems. This will also be used to track the responses received for the ABIS systems to manage futher flows.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.abis_app_code IS 'ABIS Application Code: Code of the ABIS application to which the transaction request is being done.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.request_type IS 'Request Type: Type of request that was sent to ABIS application. Eg. INSERT, IDENTIFY, etc.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.request_dtimes IS 'Request Data Time: Date and time when the ABIS request was created.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.bio_ref_id IS 'Biometric Reference ID: Biometric Reference ID of the host registration id for which requests are being sent to ABIS application.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.ref_regtrn_id IS 'Reference Transaction ID: ID of the reference registration transaction for which the ABIS transaction request is being initiated.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.req_text IS 'Requesst Text: Information that was passed to the ABIS system as part of this request.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.status_code IS 'Status Code: Current Status code of the ABIS request transaction. Refers to master.status_list.code'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.status_comment IS 'Status Comment: Comments captured as part of packet processing (if any). This can be used in case someone wants to abort the transaction, comments can be provided as additional information.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.lang_code IS 'Language Code: Code of the language used while creating this ABIS transaction.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.cr_by IS 'Created By : ID or name of the user who create / insert record.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_request.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-abis_response.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-abis_response.sql new file mode 100644 index 00000000..fd56f974 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-abis_response.sql @@ -0,0 +1,51 @@ + + +-- object: archive.mosip_regprc_abis_response | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_regprc_abis_response CASCADE; +CREATE TABLE archive.mosip_regprc_abis_response( + id character varying(36) NOT NULL, + abis_req_id character varying(36), + resp_dtimes timestamp NOT NULL, + resp_text bytea, + status_code character varying(32) NOT NULL, + status_comment character varying(256), + lang_code character varying(3) NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_abisresp PRIMARY KEY (id), + CONSTRAINT uk_abisresp UNIQUE (abis_req_id,resp_dtimes) + +); +-- ddl-end -- +COMMENT ON TABLE archive.mosip_regprc_abis_response IS 'ABIS Response: Stores all the responses that were received from ABIS systems for the request sent.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response.id IS 'Response Id: Id of the response received from ABIS application. This is a system generated unique number, can be UUID. This will be used in reference tables'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response.abis_req_id IS 'ABIS Request ID: Request id of the ABIS transaction for which ABIS response is received. This request id refers to regprc.abis_request.id'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response.resp_dtimes IS 'Response Date Time: Data and Time when the response was received.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response.resp_text IS 'Response Text: Text of the response that was received from the ABIS application.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response.status_code IS 'Status Code: Current Status code of the ABIS reponse transaction. Refers to master.status_list.code'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response.status_comment IS 'Status Comment: Comments captured as part of packet processing (if any). This can be used in case someone wants to abort the transaction, comments can be provided as additional information.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response.lang_code IS 'Language Code : For multilanguage implementation this attribute Refers master.language.code. The value of some of the attributes in current record is stored in this respective language.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response.cr_by IS 'Created By : ID or name of the user who create / insert record.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-abis_response_det.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-abis_response_det.sql new file mode 100644 index 00000000..95a9bd13 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-abis_response_det.sql @@ -0,0 +1,35 @@ + + +-- object: archive.mosip_regprc_abis_response_det | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_regprc_abis_response_det CASCADE; +CREATE TABLE archive.mosip_regprc_abis_response_det( + abis_resp_id character varying(36) NOT NULL, + matched_bio_ref_id character varying(36) NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_abisrdt PRIMARY KEY (matched_bio_ref_id,abis_resp_id) + +); +-- ddl-end -- +COMMENT ON TABLE archive.mosip_regprc_abis_response_det IS 'ABIS Response Detail: Stores details of all the ABIS responses received from ABIS system. Response details will mainly have scores, which is applicable only for identify request type.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response_det.abis_resp_id IS 'ABIS Response ID: Response id of the ABIS transaction for which ABIS response details are received. This response id refers to regprc.abis_response.id'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response_det.matched_bio_ref_id IS 'Matched BIO Reference ID: Bio Reference IDs that are potential matches with the host reference id as rececived by an ABIS application.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response_det.cr_by IS 'Created By : ID or name of the user who create / insert record.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response_det.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response_det.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response_det.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response_det.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_abis_response_det.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-reg_demo_dedupe_list.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-reg_demo_dedupe_list.sql new file mode 100644 index 00000000..ad17aeee --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-reg_demo_dedupe_list.sql @@ -0,0 +1,38 @@ + + +-- object: archive.mosip_regprc_reg_demo_dedupe_list | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_regprc_reg_demo_dedupe_list CASCADE; +CREATE TABLE archive.mosip_regprc_reg_demo_dedupe_list( + regtrn_id character varying(36) NOT NULL, + matched_reg_id character varying(39) NOT NULL, + reg_id character varying(39) NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_regded PRIMARY KEY (matched_reg_id,regtrn_id) + +); +-- ddl-end -- +COMMENT ON TABLE archive.mosip_regprc_reg_demo_dedupe_list IS 'Registration Demographic Deduplication List: List of matched UIN / RIDs, as part of demographic data.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_reg_demo_dedupe_list.regtrn_id IS 'Registration Transaction ID: ID of the demo dedupe transaction, Refers to regprc.registration_transaction.id'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_reg_demo_dedupe_list.matched_reg_id IS 'Matched Registration ID: Registration ID of the individual matching with the host registration id. It can be RID or any other id related to an individual.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_reg_demo_dedupe_list.reg_id IS 'Registration ID: Registration ID for which the matches are found as part of the demographic dedupe process.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_reg_demo_dedupe_list.cr_by IS 'Created By : ID or name of the user who create / insert record.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_reg_demo_dedupe_list.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_reg_demo_dedupe_list.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_reg_demo_dedupe_list.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_reg_demo_dedupe_list.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_reg_demo_dedupe_list.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-registration_transaction.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-registration_transaction.sql new file mode 100644 index 00000000..0fc7e467 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-regprc-registration_transaction.sql @@ -0,0 +1,68 @@ + + +-- object: archive.mosip_regprc_registration_transaction | type: TABLE -- +-- DROP TABLE IF EXISTS archive.mosip_regprc_registration_transaction CASCADE; +CREATE TABLE archive.mosip_regprc_registration_transaction( + id character varying(36) NOT NULL, + reg_id character varying(39) NOT NULL, + trn_type_code character varying(64) NOT NULL, + remarks character varying(256), + parent_regtrn_id character varying(36), + ref_id character varying(64), + ref_id_type character varying(64), + status_code character varying(36) NOT NULL, + sub_status_code character varying(36) NOT NULL, + lang_code character varying(3) NOT NULL, + status_comment character varying(256), + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean DEFAULT FALSE, + del_dtimes timestamp, + CONSTRAINT pk_regtrn_id PRIMARY KEY (id) + +); +-- ddl-end -- +-- index creation starts-- +CREATE INDEX IF NOT EXISTS idx_reg_trn_reg_id ON archive.mosip_regprc_registration_transaction USING btree (reg_id); +CREATE INDEX IF NOT EXISTS idx_reg_trn_status_code ON archive.mosip_regprc_registration_transaction USING btree (status_code); +CREATE INDEX IF NOT EXISTS idx_reg_trn_trntypecode ON archive.mosip_regprc_registration_transaction USING btree (trn_type_code); +CREATE INDEX IF NOT EXISTS idx_reg_trn_upd_dtimes ON archive.mosip_regprc_registration_transaction USING btree (upd_dtimes); +--index creation ends-- +COMMENT ON TABLE archive.mosip_regprc_registration_transaction IS 'Registration Transaction: Registration Processor Transaction table is to store ALL Registration Processor packet processing/process transaction details for ID issuance'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.id IS 'ID: Transaction id of the transactions that were recorded in registration module/application'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.reg_id IS 'Registration ID: Registration id for which these transactions are carried out at the registration client application.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.trn_type_code IS 'Transaction Type Code: Type of transaction being processed. Refers to reg.transaction_type.code'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.remarks IS 'Transaction Remarks: Current remarks/comments of the transaction'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.parent_regtrn_id IS 'Parent Registration ID: Parent transaction id that has triggered this transaction (if any). Refers to reg.registration_transaction.id'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.ref_id IS 'Reference ID: Reference id for the transaction if any'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.ref_id_type IS 'reference ID Type: reference ID type of the transaction if any'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.status_code IS 'Status Code: Current status of the transaction. Refers to code field of master.status_list table.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.sub_status_code IS 'Sub Status Code: Current sub status of the registration transaction. Refers to code field of master.status_list table.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.lang_code IS 'Language Code : For multilanguage implementation this attribute Refers master.language.code. The value of some of the attributes in current record is stored in this respective language.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.status_comment IS 'Status Comment: Comments provided by the actor during the transaction processing.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.cr_by IS 'Created By : ID or name of the user who create / insert record.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; +-- ddl-end -- +COMMENT ON COLUMN archive.mosip_regprc_registration_transaction.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +-- ddl-end -- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-resident-otp_transaction.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-resident-otp_transaction.sql new file mode 100644 index 00000000..7f3d8572 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-resident-otp_transaction.sql @@ -0,0 +1,47 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_resident +-- Release Version : 1.2.1 +-- Purpose : Database scripts for Resident Service DB. +-- Create By : Manoj SP +-- Created Date : April-2022 +-- +-- Modified Date Modified By Comments / Remarks +-- -------------------------------------------------------------------------------------------------- +-- April-2022 Manoj SP Added otp_transaction table creation scripts with comments. +----------------------------------------------------------------------------------------------------- + +-- This Table is used to save the OTP for the user whenever user requests for one using the email id / phone number to log into the application. +CREATE TABLE archive.mosip_resident_otp_transaction( + id character varying(36) NOT NULL, + ref_id character varying(1024) NOT NULL, + otp_hash character varying(512) NOT NULL, + generated_dtimes timestamp, + expiry_dtimes timestamp, + validation_retry_count smallint, + status_code character varying(36), + lang_code character varying(3), + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean, + del_dtimes timestamp, + CONSTRAINT pk_otpt_id_resident PRIMARY KEY (id) +); + +COMMENT ON TABLE archive.mosip_resident_otp_transaction IS 'All OTP related data and validation details are maintained here for Pre Registration module.'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.id IS 'OTP id is a unique identifier (UUID) used as an unique key to identify the OTP transaction'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.ref_id IS 'Reference ID is a reference information received from OTP requester which can be used while validating the OTP. AM: please give examples of ref_id'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.otp_hash IS 'Hash of id, ref_id and otp which is generated based on the configuration setup and sent to the requester application / module.'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.generated_dtimes IS 'Date and Time when the OTP was generated'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.expiry_dtimes IS 'Date Time when the OTP will be expired'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.validation_retry_count IS 'Validation retry counts of this OTP request. If the validation retry crosses the threshold limit, then the OTP will be de-activated.'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.status_code IS 'Current status of the transaction. Refers to code field of master.status_list table.'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.lang_code IS 'For multilanguage implementation this attribute Refers master.language.code. The value of some of the attributes in current record is stored in this respective language.'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.cr_by IS 'ID or name of the user who create / insert record.'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.cr_dtimes IS 'Date and Timestamp when the record is created/inserted'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.upd_by IS 'ID or name of the user who update the record with new values'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.upd_dtimes IS 'Date and Timestamp when any of the fields in the record is updated with new values.'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.is_deleted IS 'Flag to mark whether the record is Soft deleted.'; +COMMENT ON COLUMN archive.mosip_resident_otp_transaction.del_dtimes IS 'Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; +----------------------------------------------------------------------------------------------------- diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-resident_grievance_ticket.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-resident_grievance_ticket.sql new file mode 100644 index 00000000..ad2a35f2 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-resident_grievance_ticket.sql @@ -0,0 +1,50 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: resident_grievance_ticket +-- Release Version : 1.2.1 +-- Purpose : Database scripts for Resident Service DB. +-- Create By : Kamesh Shekhar Prasad +-- Created Date : December-2022 +-- +-- Modified Date Modified By Comments / Remarks +-- -------------------------------------------------------------------------------------------------- +-- +----------------------------------------------------------------------------------------------------- + +-- This Table is used to save the resident_grievance_ticket table values. +CREATE TABLE archive.mosip_resident_grievance_ticket( + id VARCHAR(64) NOT NULL, + eventId VARCHAR(64) NOT NULL, + name VARCHAR(256) NOT NULL, + emailId VARCHAR(128), + alternateEmailId VARCHAR(128), + phoneNo VARCHAR(64), + alternatePhoneNo VARCHAR(64), + message character varying(1024) NOT NULL, + hasAttachment boolean NOT NULL DEFAULT false, + status character varying(64) NOT NULL, + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean NOT NULL DEFAULT false, + del_dtimes timestamp, + CONSTRAINT pk_resgrev_id PRIMARY KEY (id) +); + +COMMENT ON TABLE archive.mosip_resident_grievance_ticket IS 'This Table is used to save the resident_grievance_ticket table values.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.id IS 'Unique Id.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.eventId IS 'Unique event id.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.emailId IS 'Unique email id.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.alternateEmailId IS 'Alternate email id.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.phoneNo IS 'Phone number.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.alternatePhoneNo IS 'Alternate Phone number.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.message IS 'Message.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.status IS 'status.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.cr_by IS 'created by.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.cr_dtimes IS 'created date and time.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.upd_by IS 'updated by.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.upd_dtimes IS 'updated date and time.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.is_deleted IS 'is deleted.'; +COMMENT ON COLUMN archive.mosip_resident_grievance_ticket.del_dtimes IS 'Deleted time-stamp.'; + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-resident_session.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-resident_session.sql new file mode 100644 index 00000000..9d17f711 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-resident_session.sql @@ -0,0 +1,34 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_resident +-- Release Version : 1.2.1 +-- Purpose : Database scripts for Resident Service DB. +-- Create By : Loganathan Sekar +-- Created Date : Jan-2023 +-- +-- Modified Date Modified By Comments / Remarks +-- -------------------------------------------------------------------------------------------------- +-- +----------------------------------------------------------------------------------------------------- + +-- This Table is used to save the user actions for the user actions table. + +CREATE TABLE archive.mosip_resident_session( + session_id character varying(128) NOT NULL, + ida_token character varying(128) NOT NULL, + login_dtimes timestamp, + ip_address character varying(128), + host character varying(128), + machine_type character varying(30), + CONSTRAINT pk_session_id PRIMARY KEY (session_id) +); + +COMMENT ON TABLE archive.mosip_resident_session IS 'This Table is used to save the user sessions.'; +COMMENT ON COLUMN archive.mosip_resident_session.session_id IS 'The unique session identifier for each login'; +COMMENT ON COLUMN archive.mosip_resident_session.ida_token IS 'The unique identifier for each user'; +COMMENT ON COLUMN archive.mosip_resident_session.login_dtimes IS 'The time when the user last logged in'; +COMMENT ON COLUMN archive.mosip_resident_session.ip_address IS 'The ip_address of device from which the user logged in'; +COMMENT ON COLUMN archive.mosip_resident_session.host IS 'The host of the site'; +COMMENT ON COLUMN archive.mosip_resident_session.machine_type IS 'The OS of device used for accessing the portal/app'; + +-- Adding index to ida_token column +CREATE INDEX idx_resident_session_ida_token ON archive.mosip_resident_session (ida_token); diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-resident_transaction.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-resident_transaction.sql new file mode 100644 index 00000000..432e5b65 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-resident_transaction.sql @@ -0,0 +1,109 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_resident +-- Release Version : 1.2.1 +-- Purpose : Database scripts for Resident Service DB. +-- Create By : Kamesh Shekhar Prasad +-- Created Date : April-2022 +-- +-- Modified Date Modified By Comments / Remarks +-- -------------------------------------------------------------------------------------------------- +-- +----------------------------------------------------------------------------------------------------- + +-- This Table is used to save the transaction related to residents. +CREATE TABLE archive.mosip_resident_transaction( + event_id VARCHAR(64) NOT NULL, + request_trn_id character varying(64) , + request_dtimes timestamp NOT NULL, + response_dtime timestamp NOT NULL, + request_type_code character varying(128) NOT NULL, + request_summary character varying(1024) NOT NULL, + status_code character varying(36) NOT NULL, + status_comment character varying(1024), + lang_code character varying(3), + ref_id_type character varying(36), + ref_id character varying(64), + token_id character varying(128) NOT NULL, + requested_entity_type character varying(64), + requested_entity_id character varying(36), + requested_entity_name character varying(128), + cr_by character varying(256) NOT NULL, + cr_dtimes timestamp NOT NULL, + upd_by character varying(256), + upd_dtimes timestamp, + is_deleted boolean NOT NULL DEFAULT false, + del_dtimes timestamp, + auth_type_code character varying(128), + static_tkn_id character varying(64), + request_signature character varying, + response_signature character varying, + olv_partner_id character varying(36), + aid character varying(64), + reference_link character varying(1024), + read_status boolean NOT NULL DEFAULT false, + pinned_status boolean NOT NULL DEFAULT false, + purpose character varying(1024), + credential_request_id character varying(256), + attribute_list character varying(255), + individual_id character varying(1024), + consent character varying(50), + tracking_id character varying(50), + CONSTRAINT pk_restrn_event_id PRIMARY KEY (event_id) +); + +COMMENT ON TABLE archive.mosip_resident_transaction IS 'This Table is used to save the transaction related to residents.'; +COMMENT ON COLUMN archive.mosip_resident_transaction.event_id IS 'Unique Id of the transaction.'; +COMMENT ON COLUMN archive.mosip_resident_transaction.aid IS 'The Application ID'; +COMMENT ON COLUMN archive.mosip_resident_transaction.request_dtimes IS 'The time when the request is received by the service'; +COMMENT ON COLUMN archive.mosip_resident_transaction.response_dtime IS 'The time when the response is received by the service'; +COMMENT ON COLUMN archive.mosip_resident_transaction.request_trn_id IS 'The unique identifier for each transaction'; +COMMENT ON COLUMN archive.mosip_resident_transaction.request_type_code IS 'The type of request'; +COMMENT ON COLUMN archive.mosip_resident_transaction.request_summary IS 'The summary of the request'; +COMMENT ON COLUMN archive.mosip_resident_transaction.status_code IS 'The current status of the request'; +COMMENT ON COLUMN archive.mosip_resident_transaction.status_comment IS 'The comment for the status of the request'; +COMMENT ON COLUMN archive.mosip_resident_transaction.lang_code IS 'The language code for the request for multi-language support'; +COMMENT ON COLUMN archive.mosip_resident_transaction.ref_id_type IS 'The type of reference id'; +COMMENT ON COLUMN archive.mosip_resident_transaction.ref_id IS 'The reference id'; +COMMENT ON COLUMN archive.mosip_resident_transaction.token_id IS 'The token id'; +COMMENT ON COLUMN archive.mosip_resident_transaction.requested_entity_type IS 'The type of the requested entity'; +COMMENT ON COLUMN archive.mosip_resident_transaction.requested_entity_id IS 'The id of the requested entity'; +COMMENT ON COLUMN archive.mosip_resident_transaction.requested_entity_name IS 'The name of the requested entity'; +COMMENT ON COLUMN archive.mosip_resident_transaction.cr_by IS 'The user who created the record'; +COMMENT ON COLUMN archive.mosip_resident_transaction.cr_dtimes IS 'The time when the record is created'; +COMMENT ON COLUMN archive.mosip_resident_transaction.upd_by IS 'The user who updated the record'; +COMMENT ON COLUMN archive.mosip_resident_transaction.upd_dtimes IS 'The time when the record is updated'; +COMMENT ON COLUMN archive.mosip_resident_transaction.is_deleted IS 'The flag to identify if the record is deleted or not'; +COMMENT ON COLUMN archive.mosip_resident_transaction.del_dtimes IS 'The time when the record is deleted'; +COMMENT ON COLUMN archive.mosip_resident_transaction.auth_type_code IS 'The type of the authentication'; +COMMENT ON COLUMN archive.mosip_resident_transaction.static_tkn_id IS 'The static token id'; +COMMENT ON COLUMN archive.mosip_resident_transaction.request_signature IS 'The signature of the request'; +COMMENT ON COLUMN archive.mosip_resident_transaction.response_signature IS 'The signature of the response'; +COMMENT ON COLUMN archive.mosip_resident_transaction.olv_partner_id IS 'The partner id'; +COMMENT ON COLUMN archive.mosip_resident_transaction.reference_link IS 'The reference link'; +COMMENT ON COLUMN archive.mosip_resident_transaction.read_status IS 'The flag to identify if the request is read or not'; +COMMENT ON COLUMN archive.mosip_resident_transaction.pinned_status IS 'The flag to identify if the request is pinned or not'; +COMMENT ON COLUMN archive.mosip_resident_transaction.purpose IS 'The purpose of the request'; +COMMENT ON COLUMN archive.mosip_resident_transaction.credential_request_id IS 'The credential request id'; + +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- Adding index to event_id column +CREATE INDEX idx_resident_transaction_event_id ON archive.mosip_resident_transaction (event_id); + +-- Adding index to token_id column +CREATE INDEX idx_resident_transaction_token_id ON archive.mosip_resident_transaction (token_id); + +-- Adding index to credential_request_id column +CREATE INDEX idx_resident_transaction_credential_request_id ON archive.mosip_resident_transaction (credential_request_id); + +-- Adding index to request_dtimes column +CREATE INDEX idx_resident_transaction_request_dtimes ON archive.mosip_resident_transaction (request_dtimes); + +-- Adding index to request_trn_id column +CREATE INDEX idx_resident_transaction_request_trn_id ON archive.mosip_resident_transaction (request_trn_id); + +-- Adding index to ref_id column +CREATE INDEX idx_resident_transaction_ref_id ON archive.mosip_resident_transaction (ref_id); + +--Adding index to read_status column +CREATE INDEX idx_resident_transaction_read_status ON archive.mosip_resident_transaction (read_status); + diff --git a/data-archive/db_scripts/mosip_archive/ddl/archive-resident_user_actions.sql b/data-archive/db_scripts/mosip_archive/ddl/archive-resident_user_actions.sql new file mode 100644 index 00000000..771f1434 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/ddl/archive-resident_user_actions.sql @@ -0,0 +1,27 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_resident +-- Release Version : 1.2.1 +-- Purpose : Database scripts for Resident Service DB. +-- Create By : Kamesh Shekhar Prasad +-- Created Date : Aug-2022 +-- +-- Modified Date Modified By Comments / Remarks +-- -------------------------------------------------------------------------------------------------- +-- +----------------------------------------------------------------------------------------------------- + +-- This Table is used to save the user actions for the user actions table. + +CREATE TABLE archive.mosip_resident_user_actions( + ida_token character varying(128) NOT NULL, + last_bell_notif_click_dtimes timestamp, + CONSTRAINT pk_ida_token PRIMARY KEY (ida_token) +); + +COMMENT ON TABLE archive.mosip_resident_user_actions IS 'This Table is used to save the user actions'; +COMMENT ON COLUMN archive.mosip_resident_user_actions.ida_token IS 'The unique identifier for each user'; +COMMENT ON COLUMN archive.mosip_resident_user_actions.last_bell_notif_click_dtimes IS 'The time when the user last clicked on the bell notification'; + +-- Adding index to ida_token column +CREATE INDEX idx_resident_user_actions_ida_token ON archive.mosip_resident_user_actions (ida_token); + diff --git a/data-archive/db_scripts/mosip_archive/deploy.properties b/data-archive/db_scripts/mosip_archive/deploy.properties new file mode 100644 index 00000000..dc3bbcb9 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/deploy.properties @@ -0,0 +1,6 @@ +DB_SERVERIP=172.16.0.162 +DB_PORT=30091 +SU_USER=postgres +DEFAULT_DB_NAME=postgres +MOSIP_DB_NAME=mosip_archive +DML_FLAG=0 diff --git a/data-archive/db_scripts/mosip_archive/deploy.sh b/data-archive/db_scripts/mosip_archive/deploy.sh new file mode 100755 index 00000000..19d2a9a0 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/deploy.sh @@ -0,0 +1,49 @@ + +## Properties file +set -e +properties_file="$1" +echo `date "+%m/%d/%Y %H:%M:%S"` ": $properties_file" +if [ -f "$properties_file" ] +then + echo `date "+%m/%d/%Y %H:%M:%S"` ": Property file \"$properties_file\" found." + while IFS='=' read -r key value + do + key=$(echo $key | tr '.' '_') + eval ${key}=\${value} + done < "$properties_file" +else + echo `date "+%m/%d/%Y %H:%M:%S"` ": Property file not found, Pass property file name as argument." +fi + +## Terminate existing connections +echo "Terminating active connections" +CONN=$(PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "SELECT count(pg_terminate_backend(pg_stat_activity.pid)) FROM pg_stat_activity WHERE datname = '$MOSIP_DB_NAME' AND pid <> pg_backend_pid()";exit;) +echo "Terminated connections" + +## Create users +echo `date "+%m/%d/%Y %H:%M:%S"` ": Creating database users" + + +MASTERCONN=$(PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "select count(1) from pg_roles where rolname IN('archiveuser')";exit;) + +if [ ${MASTERCONN} == 0 ] +then + echo `date "+%m/%d/%Y %H:%M:%S"` ": Creating Archive database user" + PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f role_dbuser.sql -v dbuserpwd=\'$DBUSER_PWD\' + ## Create DB + echo "Creating DB" + PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f db.sql + PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f ddl.sql + ## Grants + PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f grants.sql +else + echo "Archive database already exist" +fi + +## Populate tables +if [ ${DML_FLAG} == 1 ] +then + echo `date "+%m/%d/%Y %H:%M:%S"` ": Deploying DML for ${MOSIP_DB_NAME} database" + PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f dml.sql +fi + diff --git a/data-archive/db_scripts/mosip_archive/grants.sql b/data-archive/db_scripts/mosip_archive/grants.sql new file mode 100644 index 00000000..ab4c6280 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/grants.sql @@ -0,0 +1,17 @@ +\c mosip_archive + +GRANT CONNECT + ON DATABASE mosip_archive + TO archiveuser; + +GRANT USAGE + ON SCHEMA archive + TO archiveuser; + +GRANT SELECT,INSERT,UPDATE,DELETE,TRUNCATE,REFERENCES + ON ALL TABLES IN SCHEMA archive + TO archiveuser; + +ALTER DEFAULT PRIVILEGES IN SCHEMA archive + GRANT SELECT,INSERT,UPDATE,DELETE,REFERENCES ON TABLES TO archiveuser; + diff --git a/data-archive/db_scripts/mosip_archive/role_dbuser.sql b/data-archive/db_scripts/mosip_archive/role_dbuser.sql new file mode 100644 index 00000000..0125c192 --- /dev/null +++ b/data-archive/db_scripts/mosip_archive/role_dbuser.sql @@ -0,0 +1,4 @@ +CREATE ROLE archiveuser WITH + INHERIT + LOGIN + PASSWORD :dbuserpwd; diff --git a/data-archive/entrypoint.sh b/data-archive/entrypoint.sh new file mode 100755 index 00000000..0cee4907 --- /dev/null +++ b/data-archive/entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# entrypoint.sh +# test +set -e + +echo "Executing db.sh" + +bash db.sh + +echo "executed db.sh succesfully" + +sleep 1m + +echo "Executing archive.sh" + +bash archive.sh + +echo "executed archive.sh successfully" diff --git a/data-archive/requirements.txt b/data-archive/requirements.txt new file mode 100644 index 00000000..77b6a4ca --- /dev/null +++ b/data-archive/requirements.txt @@ -0,0 +1,3 @@ +psycopg2-binary==2.9.3 +configparser==5.2.3 +datetime==6