Skip to content

Conversation

@SauravBizbRolly
Copy link
Contributor

@SauravBizbRolly SauravBizbRolly commented Jan 15, 2026

πŸ“‹ Description

JIRA ID: AMM-2104,AMM-2105,AMM-2114


βœ… Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • πŸ”₯ Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • πŸ›  Refactor (change that is neither a fix nor a new feature)
  • βš™οΈ Config change (configuration file or build script updates)
  • πŸ“š Documentation (updates to docs or readme)
  • πŸ§ͺ Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • πŸš€ Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

ℹ️ Additional Information

Please describe how the changes were tested, and include any relevant screenshots, logs, or other information that provides additional context.

Summary by CodeRabbit

  • New Features
    • Added support for tracking three health campaign types: ORS, Pulse Polio, and Filariasis MDA. Users can record campaign start/end dates, counts of families or children reached, campaign photos, and audit timestamps for creation and updates.
    • Added backend metadata tracking to surface table-level details for these campaign records.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

Warning

Rate limit exceeded

@SauravBizbRolly has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 7 seconds before requesting another review.

βŒ› How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 45b0a16 and c9262fb.

πŸ“’ Files selected for processing (1)
  • src/main/resources/db/migration/dbiemr/V39__campaign_DB_IEMR.sql
πŸ“ Walkthrough

Walkthrough

Three new tables are added to the db_iemr schema to track ORS distribution, Pulse Polio immunization, and filariasis MDA campaigns, storing campaign dates, participant counts, campaign photos (JSON), user/audit fields, and related indexes.

Changes

Cohort / File(s) Summary
Database Schema Migration
src/main/resources/db/migration/dbiemr/V39__campaign_DB_IEMR.sql
Adds campaign_ors, campaign_pulse_polio, and campaign_filariasis_mda tables with PKs, start/end dates, user association, participant count fields, campaign_photos JSON columns, audit columns (created_by, updated_by, timestamps), indexes on user_id, start_date, end_date, created_date, InnoDB/utf8mb4 settings, and a metadata SELECT from information_schema.TABLES.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

πŸ‡ I hopped through rows and fields anew,
Three campaign tables β€” shiny view,
Dates, counts, and photos stored with care,
Audits watch the data there,
A rabbit cheers the schema true.

πŸš₯ Pre-merge checks | βœ… 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title consists of three JIRA ticket identifiers (AMM-2104, AMM-2105, AMM-2114) without describing what changes were made. While it references real work items, it fails to convey the actual nature of the changes to someone scanning commit history. Replace with a descriptive title such as 'Add database migration for campaign tracking tables (ORS, Pulse Polio, Filariasis MDA)' to clearly summarize the main change.
βœ… Passed checks (2 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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

@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: 1

πŸ€– Fix all issues with AI agents
In `@src/main/resources/db/migration/dbiemr/V38__campaign_DB_IEMR.sql`:
- Around line 75-90: The SELECT verification query against
information_schema.TABLES referencing TABLE_NAME IN ('campaign_ors',
'campaign_pulse_polio', 'campaign_filariasis_mda') is incorrect for this
migration because the created table is campaign_mda and such verification
queries should not live in production migrations; either remove the entire
SELECT block (the best option) or change the IN list to ('campaign_ors',
'campaign_pulse_polio', 'campaign_mda') and move this check into a separate
validation script so the migration only contains schema changes.
🧹 Nitpick comments (3)
src/main/resources/db/migration/dbiemr/V38__campaign_DB_IEMR.sql (3)

2-22: Table structure looks good, consider date validation.

The campaign_ors table has a reasonable structure with appropriate indexes. One consideration: there's no database-level constraint ensuring end_date >= start_date. If this validation isn't enforced at the application layer, you might want to add a CHECK constraint (MySQL 8.0.16+):

CHECK (end_date >= start_date)

48-69: Minor: Column ordering inconsistency.

The user_id column is positioned after campaign_photos (line 55), whereas in the other two tables it follows end_date. For consistency and easier maintenance, consider aligning the column order across all three campaign tables.

Suggested column reorder
  CREATE TABLE IF NOT EXISTS db_iemr.campaign_mda (
      id BIGINT NOT NULL AUTO_INCREMENT,
      start_date DATE NOT NULL,
      end_date DATE NOT NULL,
+     user_id INT NOT NULL,
      number_of_families INT NOT NULL DEFAULT 0,
      number_of_individuals INT NOT NULL DEFAULT 0,
      campaign_photos JSON NULL,
-     user_id INT NOT NULL,
      created_by VARCHAR(200) NULL,

71-72: Consider removing verification query from migration.

The DESCRIBE statement will execute during the migration and return a result set. Verification queries are generally better suited for post-migration validation scripts rather than the migration itself. Flyway migrations should ideally contain only DDL/DML statements that modify the schema or data.

πŸ“œ Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between ec56014 and 4d8fd5f.

πŸ“’ Files selected for processing (1)
  • src/main/resources/db/migration/dbiemr/V38__campaign_DB_IEMR.sql
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (java)
πŸ”‡ Additional comments (1)
src/main/resources/db/migration/dbiemr/V38__campaign_DB_IEMR.sql (1)

25-45: LGTM!

The campaign_pulse_polio table follows the same consistent structure as campaign_ors, with appropriate domain-specific column (number_of_children).

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link

@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: 1

πŸ€– Fix all issues with AI agents
In `@src/main/resources/db/migration/dbiemr/V39__campaign_DB_IEMR.sql`:
- Around line 71-72: The DESCRIBE verification at the end references the wrong
table name (DESCRIBE db_iemr.campaign_mda) while the migration actually creates
campaign_filariasis_mda, and DESCRIBE is a debugging command that should not be
in production migrations; remove the DESCRIBE statement entirely (delete the
line containing "DESCRIBE db_iemr.campaign_mda;") so the migration only contains
DDL for campaign_filariasis_mda and no result-set-producing verification
commands.
♻️ Duplicate comments (1)
src/main/resources/db/migration/dbiemr/V39__campaign_DB_IEMR.sql (1)

75-90: Remove verification query from production migration.

This SELECT statement against information_schema.TABLES is a verification/debugging query that doesn't belong in a production migration file. Migration scripts should only contain schema-changing DDL statements.

Verification queries can cause issues:

  • They return result sets that migration frameworks don't expect
  • They add unnecessary execution time
  • They clutter migration history

Move this to a separate validation script if post-migration verification is needed.

πŸ”§ Recommended fix: Remove the verification query
  COMMENT='MDA (Mass Drug Administration) Campaign Data';
-
-  -- Verify table created
-  DESCRIBE db_iemr.campaign_mda;
-
-
-SELECT
-    TABLE_NAME,
-    ENGINE,
-    TABLE_ROWS,
-    AVG_ROW_LENGTH,
-    DATA_LENGTH,
-    INDEX_LENGTH,
-    AUTO_INCREMENT,
-    TABLE_COLLATION,
-    CREATE_TIME,
-    UPDATE_TIME,
-    TABLE_COMMENT
-FROM information_schema.TABLES
-WHERE TABLE_SCHEMA = 'db_iemr'
-  AND TABLE_NAME IN ('campaign_ors', 'campaign_pulse_polio', 'campaign_filariasis_mda')
-ORDER BY TABLE_NAME;
-
🧹 Nitpick comments (1)
src/main/resources/db/migration/dbiemr/V39__campaign_DB_IEMR.sql (1)

48-69: Minor style inconsistencies detected.

  1. This table has extra leading indentation compared to the other two tables.
  2. The user_id column is positioned after the campaign-specific columns (line 55), whereas in campaign_ors and campaign_pulse_polio, user_id follows end_date. Consider consistent column ordering for maintainability.
♻️ Suggested column reordering for consistency
  CREATE TABLE IF NOT EXISTS db_iemr.campaign_filariasis_mda (
      id BIGINT NOT NULL AUTO_INCREMENT,
      start_date DATE NOT NULL,
      end_date DATE NOT NULL,
+     user_id INT NOT NULL,
      number_of_families INT NOT NULL DEFAULT 0,
      number_of_individuals INT NOT NULL DEFAULT 0,
      campaign_photos JSON NULL,
-     user_id INT NOT NULL,
      created_by VARCHAR(200) NULL,

@sonarqubecloud
Copy link

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