Skip to content

Adds changeset to fix Edit conditions privilege with small c - #325

Draft
sahupadma wants to merge 3 commits into
masterfrom
Update-liquibase-privilege
Draft

Adds changeset to fix Edit conditions privilege with small c#325
sahupadma wants to merge 3 commits into
masterfrom
Update-liquibase-privilege

Conversation

@sahupadma

@sahupadma sahupadma commented May 27, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • Bug Fixes
    • Standardized privilege naming conventions for conditions-related permissions and updated corresponding role mappings to ensure consistent access control throughout the system.

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5720ae82-647d-4bd7-bf12-0f63f8a9905e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This pull request adds a single Liquibase database migration that corrects the casing of two privilege names (Edit conditionsEdit Conditions, Get conditionsGet Conditions) and ensures all role associations referencing those privileges remain consistent after the rename.

Changes

Privilege Case Correction

Layer / File(s) Summary
Privilege rename migration
bahmnicore-omod/src/main/resources/liquibase.xml
A new changeSet (bahmni-core-20250527-bah-4652) conditionally renames privilege values and mirrors those changes in role_privilege table entries, with FOREIGN_KEY_CHECKS temporarily disabled during updates.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit hops through the database deep,
Where privileges rest in their structured keep,
With capital letters, all neat and refined,
The migration rolls out, leaving no trace behind! 🐰✨

🚥 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: adding a Liquibase changeset to fix the 'Edit conditions' privilege by correcting its case from lowercase 'c' to uppercase 'C'.
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
  • Commit unit tests in branch Update-liquibase-privilege

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.

@sahupadma
sahupadma marked this pull request as ready for review June 2, 2026 10:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@bahmnicore-omod/src/main/resources/liquibase.xml`:
- Around line 4691-4693: The precondition currently checks only role_privilege
and thus skips the change if role mappings are missing even when privilege rows
exist; update the <preConditions>/<sqlCheck expectedResult="1"> to also detect
the target privilege rows in the privilege table (or use an OR/UNION/EXISTS to
check both role_privilege and privilege for BINARY privilege IN ('Edit
conditions','Get conditions')) so the changeset runs when privilege rows are
present even if role_privilege rows are absent; adjust the sqlCheck expression
inside the preConditions block accordingly.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 327f7b78-20a9-4e12-964f-988de92d6cfe

📥 Commits

Reviewing files that changed from the base of the PR and between d12197d and 8bc2865.

📒 Files selected for processing (1)
  • bahmnicore-omod/src/main/resources/liquibase.xml

Comment on lines +4691 to +4693
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">SELECT IF(count(*) > 0, 1, 0) FROM role_privilege WHERE BINARY privilege IN ('Edit conditions', 'Get conditions')</sqlCheck>
</preConditions>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Broaden the precondition beyond role_privilege.

The old privilege records were created independently at Line 3688 and Line 3699, while the role mappings were added later at Line 3709 and Line 3719. If an installation still has privilege rows but no matching role_privilege rows, this MARK_RAN precondition skips the migration entirely and the casing bug remains in privilege.

Suggested fix
-        <preConditions onFail="MARK_RAN">
-            <sqlCheck expectedResult="1">SELECT IF(count(*) > 0, 1, 0) FROM role_privilege WHERE BINARY privilege IN ('Edit conditions', 'Get conditions')</sqlCheck>
-        </preConditions>
+        <preConditions onFail="MARK_RAN">
+            <sqlCheck expectedResult="1">
+                SELECT IF(
+                    EXISTS (SELECT 1 FROM privilege WHERE BINARY privilege IN ('Edit conditions', 'Get conditions'))
+                    OR EXISTS (SELECT 1 FROM role_privilege WHERE BINARY privilege IN ('Edit conditions', 'Get conditions')),
+                    1,
+                    0
+                )
+            </sqlCheck>
+        </preConditions>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">SELECT IF(count(*) > 0, 1, 0) FROM role_privilege WHERE BINARY privilege IN ('Edit conditions', 'Get conditions')</sqlCheck>
</preConditions>
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
SELECT IF(
EXISTS (SELECT 1 FROM privilege WHERE BINARY privilege IN ('Edit conditions', 'Get conditions'))
OR EXISTS (SELECT 1 FROM role_privilege WHERE BINARY privilege IN ('Edit conditions', 'Get conditions')),
1,
0
)
</sqlCheck>
</preConditions>
🤖 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 `@bahmnicore-omod/src/main/resources/liquibase.xml` around lines 4691 - 4693,
The precondition currently checks only role_privilege and thus skips the change
if role mappings are missing even when privilege rows exist; update the
<preConditions>/<sqlCheck expectedResult="1"> to also detect the target
privilege rows in the privilege table (or use an OR/UNION/EXISTS to check both
role_privilege and privilege for BINARY privilege IN ('Edit conditions','Get
conditions')) so the changeset runs when privilege rows are present even if
role_privilege rows are absent; adjust the sqlCheck expression inside the
preConditions block accordingly.

@sonarqubecloud

sonarqubecloud Bot commented Jun 2, 2026

Copy link
Copy Markdown

@sahupadma
sahupadma marked this pull request as draft June 4, 2026 06:34
# Conflicts:
#	bahmnicore-omod/src/main/resources/liquibase.xml
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.

1 participant