Sha256: 0aa5d622f073ecc8585ad76a2d1823336a3cb81f5cab531c82091867d341cfec

Contents?: true

Size: 1.05 KB

Versions: 19

Compression:

Stored size: 1.05 KB

Contents

class RenameJobNameToJobCategory < ActiveRecord::Migration[4.2]
  def up
    rename_column :templates, :job_name, :job_category
    rename_column :job_invocations, :job_name, :job_category
    JobTemplate.where(:description_format => '%{job_name} %{command}').update_all(:description_format => 'Run %{command}')
    JobTemplate.where("description_format LIKE '%\%{job_name}%'").find_each do |template|
      JobTemplate.where(:id => template.id).update_all(:description_format => template.description_format.gsub('%{job_name}', '%{job_category}'))
    end
  end

  def down
    JobTemplate.where("description_format LIKE '%\%{job_category}%'").find_each do |template|
      JobTemplate.where(:id => template.id).update_all(:description_format => template.description_format.gsub('%{job_category}', '%{job_name}'))
    end
    JobTemplate.where(:description_format => 'Run %{command}').update_all(:description_format => '%{job_name} %{command}')
    rename_column :templates, :job_category, :job_name
    rename_column :job_invocations, :job_category, :job_name
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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