Sha256: 796779d019d60863c7c6db90d1730f9449d099ba398ff6fbe129ae635b3c2a17

Contents?: true

Size: 1.14 KB

Versions: 193

Compression:

Stored size: 1.14 KB

Contents

class AddActionToContentViewHistories < ActiveRecord::Migration[4.2]
  def up
    add_column :katello_content_view_histories, :action, :integer, default: 0

    Katello::ContentViewHistory.reset_column_information

    Katello::ContentViewHistory.find_each do |history|
      task_label = history.task.try(:label)
      unless task_label
        history.delete
        next
      end

      case task_label
      when "Actions::Katello::ContentViewVersion::Export"
        history.action = Katello::ContentViewHistory.actions[:export]
      when "Actions::Katello::ContentView::Publish", "Actions::Katello::ContentView::IncrementalUpdates"
        history.action = Katello::ContentViewHistory.actions[:publish]
      when "Actions::Katello::ContentView::Promote"
        history.action = Katello::ContentViewHistory.actions[:promotion]
      when "Actions::Katello::ContentView::Remove"
        history.action = Katello::ContentViewHistory.actions[:removal]
      else
        fail "Cannot determine action for task label '#{task_label}'"
      end

      history.save!
    end
  end

  def down
    remove_column :katello_content_view_histories, :action
  end
end

Version data entries

193 entries across 193 versions & 1 rubygems

Version Path
katello-4.7.1 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.6.2.1 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.6.2 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.7.0 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.6.1 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.7.0.rc2 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.7.0.rc1 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.4.2.2 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.4.2.1 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.4.2 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.5.1 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.6.0 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.6.0.rc2 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.6.0.rc1 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.5.0 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.5.0.rc2 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.4.1 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.5.0.rc1 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.4.0.2 db/migrate/20160923143611_add_action_to_content_view_histories.rb
katello-4.4.0.1 db/migrate/20160923143611_add_action_to_content_view_histories.rb