Skip to content

Fix regression bug where *.once.sql scripts never got executed

Mark Macdonald requested to merge 4-once-scripts-bug into main

This merge request resolves a regression bug where *.once.sql scripts would never get executed, even the first time round.

The cause of the bug was a logic error when removing an obsolete feature from the migrator tool. The tool used to have an option called backfit, which was only needed when we first started using the migrator on the production database. The backfit command descript was Backfit migrations to a legacy database (skips all .once.sql scripts even the first time). The old code looked like this:

Screenshot_2021-09-17_at_16.23.17

When I removed the backfit option, I didn't properly update this logic, and so the SQL commands were always missing for *.once.scripts*, as shown here:

Screenshot_2021-09-17_at_16.05.39

I've added a test to reproduce the bug, and then fixed the logic. There was actually an integration test that would have caught this, if the test itself didn't have a mistake, so I've corrected that too. And I've added an integration test to cover re-executing altered scripts with the force option set, showing that *.once.sql scripts don't get re-executed.

Closes #4 (closed)

Merge request reports