Sha256: dab82641831dc0f1d5cb9886c9496decda7b1c0e660d1da62334cd41f7caebfb

Contents?: true

Size: 726 Bytes

Versions: 19

Compression:

Stored size: 726 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).find_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

19 entries across 19 versions & 1 rubygems

Version Path
foreman_remote_execution-14.1.1 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-14.1.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-14.0.2 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-14.0.1 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-13.2.6 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-14.0.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-13.2.5 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-13.2.4 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-13.2.3 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-13.2.2 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-12.0.7 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-13.2.1 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-13.2.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-13.0.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-12.0.5 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-12.0.4 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-12.0.1 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-12.0.2 db/migrate/20220321101835_rename_ssh_provider_to_script.rb
foreman_remote_execution-12.0.0 db/migrate/20220321101835_rename_ssh_provider_to_script.rb