Class: Redmine::Installer::Step::Upgrade

Inherits:
Base
  • Object
show all
Defined in:
lib/redmine-installer/steps/upgrade.rb

Instance Attribute Summary

Attributes inherited from Base

#base, #index, #ran

Instance Method Summary collapse

Methods inherited from Base

#down, #final_step, #initialize, #load, #print_footer, #print_header, #print_title, #redmine_plugins, #save

Methods included from Utils

included

Constructor Details

This class inherits a constructor from Redmine::Installer::Step::Base

Instance Method Details

#upObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/redmine-installer/steps/upgrade.rb', line 6

def up
  # Copy database.yml
  copy_config_file(plugin::Database::DATABASE_YML_PATH)

  # Copy configuration.yml
  copy_config_file(plugin::EmailSending::CONFIGURATION_YML_PATH)

  # Copy files
  FileUtils.cp_r(File.join(base.redmine_root, 'files'), base.tmp_redmine_root)

  # Copy plugins
  tmp_plugin_dir = File.join(base.tmp_redmine_root, 'plugins')
  redmine_plugins.each do |plugin|
    # Copy only plugins which are not part of package
    # - this is a upgrade so package should contains newer version
    unless Dir.exist?(File.join(tmp_plugin_dir, File.basename(plugin)))
      FileUtils.cp_r(plugin, tmp_plugin_dir)
    end
  end

  Dir.chdir(base.tmp_redmine_root) do
    command.bundle_install(base.env)
    command.rake_db_migrate(base.env)
    command.rake_redmine_plugin_migrate(base.env) if some_plugins?
    command.rake_generate_secret_token(base.env)

    # Other plugins can have post-install procedure
    plugin::RedminePlugin.all.each do |plugin|
      plugin.upgrade(base)
    end
  end

  # Delete content of redmine_root
  Dir.glob(File.join(base.redmine_root, '{*,.*}')) do |entry|
    next if entry.end_with?('.') || entry.end_with?('..')

    FileUtils.remove_entry_secure(entry)
  end
end