Actions
Defect #37686
openPlugin migration does not work properly if called multiple times with different target versions
Status:
New
Priority:
Normal
Assignee:
-
Category:
Plugin API
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Affected version:
Description
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)
# ...do 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::Migrator.instance_variable_get(:@all_versions)&.delete('some_plugin')
Redmine::Plugin.migrate('some_plugin', 3)
No data to display
Actions