Class: RedminePluginsHelper::Migrations

Inherits:
Object
  • Object
show all
Defined in:
lib/redmine_plugins_helper/migrations.rb

Class Method Summary collapse

Class Method Details

.db_all_versionsObject



29
30
31
32
# File 'lib/redmine_plugins_helper/migrations.rb', line 29

def db_all_versions
  ::ActiveRecord::SchemaMigration.create_table
  ::ActiveRecord::SchemaMigration.all.pluck(:version)
end

.db_versionsObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/redmine_plugins_helper/migrations.rb', line 17

def db_versions
  r = {}
  db_all_versions.each do |v|
    pv = parse_plugin_version(v)
    next unless pv

    r[pv[:plugin]] ||= []
    r[pv[:plugin]] << pv[:timestamp]
  end
  r
end

.local_versionsObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/redmine_plugins_helper/migrations.rb', line 6

def local_versions
  r = {}
  Redmine::Plugin.registered_plugins.each_value do |p|
    p.migrations.each do |ts|
      r[p.id] ||= []
      r[p.id] << ts
    end
  end
  r
end

.parse_plugin_version(version) ⇒ Object



34
35
36
37
38
39
# File 'lib/redmine_plugins_helper/migrations.rb', line 34

def parse_plugin_version(version)
  m = version.match(/^(\d+)\-(\S+)$/)
  return nil unless m

  { plugin: m[2].to_sym, timestamp: m[1].to_i }
end