Database migrations don't run correctly for plugins when specifying the `VERSION` env variable
|Target version:||Candidate for next major release|
tl;dr: When comparing versions, the current_version is set to the core's latest migration instead of the plugin's latest.
Steps to reproduce:
1. Install any plugin with migrations, for example:
cd redmine/plugins git clone https://github.com/ixti/redmine_tags.git bundle install rake redmine:plugins:migrate NAME=redmine_tags
2. Undo the last migration of that plugin:
rake redmine:plugins:migrate NAME=redmine_tags VERSION=20151209153801
3. Migrate to the latest version again, but specifying the version this time:
rake redmine:plugins:migrate NAME=redmine_tags VERSION=20180122193833
Expected behaviour: the 20180122193833 migration is executed.
Actual behaviour: the 20180122193833 is not executed.
This is because redmine core's latest migration is 20180923091603 which is greather that the plugin's 20180122193833.
The attached fix defines a `migrate` method for the `Redmine::Plugin::MigrationContext` class that makes sure to pass along the current plugin's latest migration. Using the default migrate method defined in activerecord executes a `current_version` that looks for the most current migration in the list of all migrations (core and plugins).
Note: I have not run any tests with this patch.
#1 Updated by Codruț Gușoi about 1 year ago
Test run available here: https://gitlab.com/sdwolfz/redmine/-/jobs/187237412
Although... I am not sure how to add a test that checks for this exact error.