Project

General

Profile

Actions

Defect #37686

closed

Plugin migrations are skipped or fail due to stale cached versions when a plugin is migrated more than once in the same process

Added by crypto gopher about 4 years ago. Updated 7 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Plugin API
Target version:
Resolution:
Fixed
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)

Files


Related issues

Related to Redmine - Patch #28934: Support migration context for pluginsClosedJean-Philippe LangActions
Actions

Also available in: Atom PDF