Defect #31116 » redmine-4.0.2.plugin-upgrade.patch
| /usr/share/redmine/redmine-4.0.2/lib/redmine/plugin.rb 2019-04-17 17:35:44.815629390 +0200 | ||
|---|---|---|
|
def open
|
||
|
Migrator.new(:up, migrations, nil)
|
||
|
end
|
||
|
def set_current_plugin(p)
|
||
|
@current_plugin = p
|
||
|
end
|
||
|
def get_all_versions(plugin = @current_plugin)
|
||
|
# Delete migrations that don't match .. to_i will work because the number comes first
|
||
|
@all_versions ||= {}
|
||
|
@all_versions[plugin.id.to_s] ||= begin
|
||
|
sm_table = ::ActiveRecord::SchemaMigration.table_name
|
||
|
migration_versions = ActiveRecord::Base.connection.select_values("SELECT version FROM #{sm_table}")
|
||
|
versions_by_plugins = migration_versions.group_by { |version| version.match(/-(.*)$/).try(:[], 1) }
|
||
|
@all_versions = versions_by_plugins.transform_values! {|versions| versions.map!(&:to_i).sort! }
|
||
|
@all_versions[plugin.id.to_s] || []
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
class Migrator < ActiveRecord::Migrator
|
||
| ... | ... | |
|
self.current_plugin = plugin
|
||
|
return if current_version(plugin) == version
|
||
|
MigrationContext.new(plugin.migration_directory).migrate(version)
|
||
|
ctx = MigrationContext.new(plugin.migration_directory)
|
||
|
ctx.set_current_plugin(plugin)
|
||
|
ctx.migrate(version)
|
||
|
end
|
||
|
def get_all_versions(plugin = current_plugin)
|
||