[MOSIP-37808] Updated DB attributes of MOSIP for audit service#269
[MOSIP-37808] Updated DB attributes of MOSIP for audit service#269abhishek8shankar wants to merge 1 commit into
Conversation
Signed-off-by: Abhi <abhishek.shankarcs@gmail.com>
WalkthroughThis PR parameterizes the audit database deployment scripts by replacing hardcoded database and role names ( ChangesParameterized Database Deployment Configuration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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_audit/db.sql`:
- Line 1: The SQL uses the unquoted substitution token :mosipdbname which fails
for mixed-case or special-character database names; update all occurrences
(e.g., the CREATE DATABASE statement and the other DDL/DML uses at the noted
spots) to use psql identifier-quoting syntax :"mosipdbname" so the substituted
name is treated as an identifier, not a raw token; ensure every instance of
:mosipdbname in the script is replaced with :"mosipdbname" (including the CREATE
DATABASE, any GRANT/OWNER or CONNECT statements) so names with hyphens or
upper-case are handled correctly.
In `@db_scripts/mosip_audit/deploy.sh`:
- Around line 25-37: The psql invocations in deploy.sh use unquoted shell
variables (e.g., $SU_USER, $DB_SERVERIP, $DB_PORT, $DEFAULT_DB_NAME,
$MOSIP_DB_NAME, $DB_UNAME, $DBUSER_PWD) which can trigger word-splitting or glob
expansion; update every PGPASSWORD=... and psql command (the lines invoking psql
to run drop_db.sql, drop_role.sql, db.sql, ddl.sql, role_dbuser.sql, grants.sql)
to wrap each variable expansion in double quotes (for example
"--username=\"$SU_USER\"" and "--host=\"$DB_SERVERIP\"" and "-v
mosipdbname=\"$MOSIP_DB_NAME\"" and "-v dbuserpwd=\"$DBUSER_PWD\"") so values
with spaces/special chars are passed safely.
In `@db_scripts/mosip_audit/grants.sql`:
- Around line 3-5: The GRANT statement hardcodes the role "audituser" instead of
using the role parameter, so change the GRANT CONNECT statement to grant the
privilege to the configured role parameter (replace the literal audituser with
the parameter :dbuname or DB_UNAME used elsewhere); update the line in
grants.sql where GRANT CONNECT ON DATABASE :mosipdbname TO audituser is defined
so it references the role variable (:dbuname/DB_UNAME) consistently with your
templating.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 45538f99-4c04-4537-b529-e492416a2abe
📒 Files selected for processing (8)
db_scripts/mosip_audit/db.sqldb_scripts/mosip_audit/ddl.sqldb_scripts/mosip_audit/deploy.propertiesdb_scripts/mosip_audit/deploy.shdb_scripts/mosip_audit/drop_db.sqldb_scripts/mosip_audit/drop_role.sqldb_scripts/mosip_audit/grants.sqldb_scripts/mosip_audit/role_dbuser.sql
Summary by CodeRabbit
Release Notes