Project

General

Profile

Actions

Defect #31116

closed

Database migrations don't run correctly for plugins when specifying the `VERSION` env variable

Added by Anonymous over 5 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Plugin API
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

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.


Files

Actions

Also available in: Atom PDF