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-9.1.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-8.2.1 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-8.2.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-9.0.1 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-9.0.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-8.1.2 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-8.1.1 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-8.1.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-7.2.2 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-7.2.1 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-7.2.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-8.0.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-7.1.1 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-7.1.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-7.0.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-6.2.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-6.1.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb