1899 Updated db_upgrade scripts for audit-manager#292
Conversation
Signed-off-by: abhishek8shankar <abhishek.shankarcs@gmail.com>
WalkthroughThe mosip_audit upgrade/rollback SQL scripts and driving shell script are updated to replace hardcoded database name ( ChangesParameterized DB Connection and Privileges
Estimated code review effort: 1 (Trivial) | ~5 minutes Sequence Diagram(s)sequenceDiagram
participant upgrade.sh
participant upgrade.properties
participant psql
upgrade.sh->>upgrade.properties: read MOSIP_DB_NAME, DB_UNAME
upgrade.sh->>psql: terminate connections (-v mosipdbname, -v dbuname)
upgrade.sh->>psql: run upgrade SQL (-v mosipdbname, -v dbuname)
upgrade.sh->>psql: run rollback SQL (-v mosipdbname, -v dbuname)
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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.
🧹 Nitpick comments (1)
db_upgrade_scripts/mosip_audit/upgrade.sh (1)
24-24: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueQuote the new
-vvariable expansions.The newly added
-v mosipdbname=$MOSIP_DB_NAME -v dbuname=$DB_UNAMEargs are unquoted, matching flagged shellcheck (SC2086) warnings on these lines. Since these values come from the properties file (not user input) the practical risk is low, but quoting avoids word-splitting/globbing surprises if a value ever contains spaces or glob characters.🔧 Proposed fix
-CONN=$(PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 -v mosipdbname=$MOSIP_DB_NAME -v dbuname=$DB_UNAME --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;) +CONN=$(PGPASSWORD="$SU_USER_PWD" psql -v ON_ERROR_STOP=1 -v mosipdbname="$MOSIP_DB_NAME" -v dbuname="$DB_UNAME" --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;)Also applies to: 33-33, 43-43
🤖 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_upgrade_scripts/mosip_audit/upgrade.sh` at line 24, The psql command in upgrade.sh passes new -v variables without quoting, which can trigger word-splitting and shellcheck SC2086 warnings. Update the command construction in the affected upgrade steps to quote the mosipdbname and dbuname expansions while keeping the existing psql invocation and variable names intact. Apply the same quoting pattern consistently wherever these -v arguments are used in the script.Source: Linters/SAST tools
🤖 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.
Nitpick comments:
In `@db_upgrade_scripts/mosip_audit/upgrade.sh`:
- Line 24: The psql command in upgrade.sh passes new -v variables without
quoting, which can trigger word-splitting and shellcheck SC2086 warnings. Update
the command construction in the affected upgrade steps to quote the mosipdbname
and dbuname expansions while keeping the existing psql invocation and variable
names intact. Apply the same quoting pattern consistently wherever these -v
arguments are used in the script.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d1d3a9b8-b82d-4409-8078-26694454eeb0
📒 Files selected for processing (4)
db_upgrade_scripts/mosip_audit/sql/1.1.5.5_to_1.2.0.1-B1_rollback.sqldb_upgrade_scripts/mosip_audit/sql/1.1.5.5_to_1.2.0.1-B1_upgrade.sqldb_upgrade_scripts/mosip_audit/upgrade.propertiesdb_upgrade_scripts/mosip_audit/upgrade.sh
Summary by CodeRabbit