Project

General

Profile

Defect #31116 » 0001-Fixes-plugin-migration-with-specific-version.patch

Anonymous, 2019-03-28 23:51

View differences:

lib/redmine/plugin.rb
515 515
      def open
516 516
        Migrator.new(:up, migrations, nil)
517 517
      end
518

  
519
      def migrate(target_version = nil, current_version = nil)
520
        case
521
        when target_version.nil?
522
          up(target_version)
523
        when current_version == 0 && target_version == 0
524
          []
525
        when current_version && current_version > target_version
526
          down(target_version)
527
        else
528
          up(target_version)
529
        end
530
      end
518 531
    end
519 532

  
520 533
    class Migrator < ActiveRecord::Migrator
......
525 538
        # Runs the migrations from a plugin, up (or down) to the version given
526 539
        def migrate_plugin(plugin, version)
527 540
          self.current_plugin = plugin
528
          return if current_version(plugin) == version
541
          current = current_version(plugin)
542
          return if current == version
529 543

  
530
          MigrationContext.new(plugin.migration_directory).migrate(version)
544
          MigrationContext.new(plugin.migration_directory).migrate(version, current)
531 545
        end
532 546

  
533 547
        def get_all_versions(plugin = current_plugin)
(1-1/3)