Sha256: 8cb2468239a18924e7a4cc910128cc310f2cf945b4b8a2458f796518f3aa3907

Contents?: true

Size: 721 Bytes

Versions: 37

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

class RenameSshProviderToScript < ActiveRecord::Migration[6.0]

  def do_change(from, to, from_re, new_label)
    setting = Setting.find_by(:name => 'remote_execution_form_job_template')
    default_template = nil

    Template.where(:provider_type => from).each do |t|
      default_template = t if t.name == setting&.value
      t.provider_type = to
      t.name = t.name.gsub(from_re, new_label)
      t.save!
    end

    if default_template
      setting.value = default_template.name
      setting.save!
    end
  end

  def up
    do_change 'SSH', 'script', /SSH Default$/, 'Script Default'
  end

  def down
    do_change 'script', 'SSH', /Script Default$/, 'SSH Default'
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
foreman_remote_execution-10.1.3 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-11.1.3 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-10.1.2 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-10.1.1 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-11.1.1 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-11.1.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-10.1.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-8.3.3 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-8.3.2 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-11.0.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-10.0.7 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-8.3.1 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-10.0.6 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-10.0.5 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-10.0.4 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-10.0.3 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-10.0.2 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-10.0.1 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-10.0.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-8.3.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb