Skip to content

[MOSIP-37808] Updated DB attributes of MOSIP esignet#1885

Merged
ckm007 merged 2 commits into
mosip:developfrom
abhishek8shankar:MOSIP-37808
May 20, 2026
Merged

[MOSIP-37808] Updated DB attributes of MOSIP esignet#1885
ckm007 merged 2 commits into
mosip:developfrom
abhishek8shankar:MOSIP-37808

Conversation

@abhishek8shankar
Copy link
Copy Markdown
Member

@abhishek8shankar abhishek8shankar commented May 20, 2026

Summary by CodeRabbit

  • Chores
    • Parameterized database initialization and deployment to support configurable database names and user credentials at deploy time.
    • Updated database configuration values (host, repo URL, credentials, port, branch and default DB) to allow more flexible deployment setups.

Review Change Stack

Signed-off-by: Abhi <abhishek.shankarcs@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b792b3de-2303-4297-9043-dff4f952d151

📥 Commits

Reviewing files that changed from the base of the PR and between d8abb73 and 6e9c0fa.

📒 Files selected for processing (1)
  • db_scripts/init_values.yaml

Walkthrough

Database initialization and deployment scripts are refactored to accept configurable database names and usernames via environment variables and psql parameters, replacing hardcoded identifiers throughout the pipeline.

Changes

Database Configuration Parameterization

Layer / File(s) Summary
Configuration and environment setup
db_scripts/init_values.yaml, db_scripts/mosip_esignet/deploy.properties
Initialization config adds scriptsDir, dbName, dbUser, defaultDb, updates host, and adds repoUrl. deploy.properties adds DB_UNAME=esignetuser.
SQL scripts parameterized for database/user names
db_scripts/mosip_esignet/drop_db.sql, drop_role.sql, role_dbuser.sql, db.sql, ddl.sql, grants.sql, dml.sql
SQL scripts switch from hardcoded mosip_esignet / esignetuser to psql placeholders :mosipdbname and :dbuname for CREATE/DROP/CONNECT/GRANT and role creation statements.
Deployment script variable passing
db_scripts/mosip_esignet/deploy.sh
deploy.sh updated to pass -v mosipdbname=$MOSIP_DB_NAME and -v dbuname=$DB_UNAME to psql for teardown, user/DB creation, DDL, grants, and conditional DML execution.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through scripts at break of dawn,
Replaced the stones where names were drawn—
Now :mosipdbname can roam and play,
:dbuname hops in, leads the way,
Deploys sing softly: "Use any name today!"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: parameterizing database configuration attributes across multiple SQL deployment scripts for the MOSIP esignet module.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
db_scripts/mosip_esignet/db.sql (1)

9-11: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Hardcoded database name breaks parameterized deployments.

COMMENT ON DATABASE and \c still target mosip_esignet, so custom MOSIP_DB_NAME runs will fail or modify the wrong DB.

Suggested fix
-COMMENT ON DATABASE mosip_esignet IS 'e-Signet related data is stored in this database';
+COMMENT ON DATABASE :"mosipdbname" IS 'e-Signet related data is stored in this database';

-\c mosip_esignet postgres
+\c :mosipdbname postgres
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@db_scripts/mosip_esignet/db.sql` around lines 9 - 11, The script currently
hardcodes the database name in the COMMENT ON DATABASE and psql connect command
(\c) targeting "mosip_esignet"; update both uses to reference the deploy-time
variable (MOSIP_DB_NAME) instead of the literal string so parameterized
deployments connect to and annotate the correct database (replace the literal
"mosip_esignet" in the COMMENT ON DATABASE statement and the \c command with the
MOSIP_DB_NAME substitution mechanism your SQL runner uses).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@db_scripts/mosip_esignet/deploy.sh`:
- Around line 34-35: The psql invocations (the PGPASSWORD=... psql ... -f
drop_db.sql -v mosipdbname=$MOSIP_DB_NAME and the drop_role.sql call with -v
dbuname=$DB_UNAME, plus other psql calls using -v dbuserpwd=\'$DBUSER_PWD\' )
use unquoted shell expansions which can cause word-splitting or break arguments
and the literal-quoted password is unsafe; fix by wrapping each variable
expansion in double quotes (e.g. use -v mosipdbname="$MOSIP_DB_NAME", -v
dbuname="$DB_UNAME" and pass PGPASSWORD="$SU_USER_PWD" and -v
dbuserpwd="$DBUSER_PWD") so psql receives each value as a single argument and
passwords with spaces or quotes are handled correctly.
- Around line 34-35: After loading the properties via eval, add a fail-fast
validation block that checks required environment variables (at minimum
MOSIP_DB_NAME and DB_UNAME, and also SU_USER_PWD, SU_USER, DB_SERVERIP, DB_PORT,
DEFAULT_DB_NAME) are set and non-empty; if any are missing, print a clear error
to stderr and exit non‑zero before running any psql DROP or CREATE commands
(these checks should be placed immediately after the properties are sourced to
protect the psql invocations that use MOSIP_DB_NAME/DB_UNAME on lines running
psql -f drop_db.sql, drop_role.sql and the subsequent psql calls).

In `@db_scripts/mosip_esignet/role_dbuser.sql`:
- Around line 1-4: The CREATE ROLE statement uses raw psql variable substitution
(:dbuname and :dbuserpwd) which is unsafe for identifiers and literals; update
the statement in role_dbuser.sql to use psql quoting: use :"dbuname" for the
role identifier and :'dbuserpwd' for the password literal, and apply the same
pattern to other files (grants.sql, drop_role.sql, db.sql) wherever unquoted
:var substitutions appear so identifiers use :"name" and string values use
:'name'.

---

Outside diff comments:
In `@db_scripts/mosip_esignet/db.sql`:
- Around line 9-11: The script currently hardcodes the database name in the
COMMENT ON DATABASE and psql connect command (\c) targeting "mosip_esignet";
update both uses to reference the deploy-time variable (MOSIP_DB_NAME) instead
of the literal string so parameterized deployments connect to and annotate the
correct database (replace the literal "mosip_esignet" in the COMMENT ON DATABASE
statement and the \c command with the MOSIP_DB_NAME substitution mechanism your
SQL runner uses).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 72e4c2ff-0943-4b06-8f25-ca463fa0f9e2

📥 Commits

Reviewing files that changed from the base of the PR and between 5e90e3c and d8abb73.

📒 Files selected for processing (10)
  • db_scripts/init_values.yaml
  • db_scripts/mosip_esignet/db.sql
  • db_scripts/mosip_esignet/ddl.sql
  • db_scripts/mosip_esignet/deploy.properties
  • db_scripts/mosip_esignet/deploy.sh
  • db_scripts/mosip_esignet/dml.sql
  • db_scripts/mosip_esignet/drop_db.sql
  • db_scripts/mosip_esignet/drop_role.sql
  • db_scripts/mosip_esignet/grants.sql
  • db_scripts/mosip_esignet/role_dbuser.sql

Comment thread db_scripts/mosip_esignet/deploy.sh
Comment thread db_scripts/mosip_esignet/role_dbuser.sql
Signed-off-by: Abhishek S <127825992+abhishek8shankar@users.noreply.github.com>
@ckm007 ckm007 merged commit 6c96063 into mosip:develop May 20, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants