Defect #37686

Plugin migration does not work properly if called multiple times with different target versions

Added by crypto gopher 2 months ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:


Category:Plugin API
Target version:-
Resolution: Affected version:5.0.2


When testing plugin migrations it is necessary to call plugin migrations more than once, e.g.:

# migrate to version A
Redmine::Plugin.migrate('some_plugin', 2)

# some plugin specific database filling...

# try to migrate to version B and see if migration gave proper results
Redmine::Plugin.migrate('some_plugin', 3)

The problem is it does not work as expected. Installed migrations are listed and cached in Redmine::Plugin::Migrator @all_versions variable during first migrate() run. Then it is never updated and subsequent migrate() calls operate on its outdated contents.

Quick workaround is to clear @all_versions variable like this:

Redmine::Plugin.migrate('some_plugin', 2)


Redmine::Plugin.migrate('some_plugin', 3)

Also available in: Atom PDF