Skip to content

FINERACT-2598: Backfill repaymentStartDateType values from loan product to loan level - Part 2#5826

Open
mariiaKraievska wants to merge 1 commit intoapache:developfrom
openMF:FINERACT-2598/repayment-start-date-type-config-applied-to-existing-loans-step-2
Open

FINERACT-2598: Backfill repaymentStartDateType values from loan product to loan level - Part 2#5826
mariiaKraievska wants to merge 1 commit intoapache:developfrom
openMF:FINERACT-2598/repayment-start-date-type-config-applied-to-existing-loans-step-2

Conversation

@mariiaKraievska
Copy link
Copy Markdown
Contributor

Description

Describe the changes made and why they were made. (Ignore if these details are present on the associated Apache Fineract JIRA ticket.)

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per our guidelines
  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
  • Create/update unit or integration tests for verifying the changes made.
  • Follow our coding conventions.
  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
  • This PR must not be a "code dump". Large changes can be made in a branch, with assistance. Ask for help on the developer mailing list.

Your assigned reviewer(s) will follow our guidelines for code reviews.

@mariiaKraievska mariiaKraievska marked this pull request as ready for review May 6, 2026 13:24

SET v_rows_updated = ROW_COUNT();
COMMIT;
DO SLEEP(0.1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We dont need sleep.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done


EXIT WHEN v_rows_updated = 0;
COMMIT;
PERFORM pg_sleep(0.1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We dont need sleep

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, removed the sleeps in both changeSets. Thanks!

@mariiaKraievska mariiaKraievska force-pushed the FINERACT-2598/repayment-start-date-type-config-applied-to-existing-loans-step-2 branch from f688499 to cb033bd Compare May 7, 2026 12:14
</and>
</preConditions>
<sql splitStatements="false">
DO $$
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does PostgreSQL allow COMMIT inside DO $$ blocks?
Just checking because I thought transaction control inside anonymous blocks could fail.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, since PostgreSQL 11, COMMIT and ROLLBACK inside DO blocks is allowed https://www.postgresql.org/docs/current/plpgsql-transactions.html when they aren’t nested in an outer transaction . That’s why this changeSet uses runInTransaction="false". Also I tested it locally, and for me migration went well on both postgres and mysql

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi, thanks for replying, pls resolve this comment when it gets reviewed by adam

If possible can you share any data snapshot in which I can test these too?
Asking for myself so that I can fiddle around with schema locally.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hello, no problem - i’ll resolve it once Adam takes a look.
I don’t really have a data snapshot to share, but easiest thing is: on the code base without migration from this PR to just run the e2e tests for loans (from fineract-e2e-tests-runner - any of the loan features), they’ll create a bunch of records in m_loan for you. After that you can null out repayment_start_date_type_enum for some of them to simulate the pre-backfill state and run the migration to see it in action.

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.

3 participants