Sha256: 7b79b0a6d97f7b9444b6975fac52b5171ee5feee902d000758509e8a402f4d4c

Contents?: true

Size: 1.57 KB

Versions: 55

Compression:

Stored size: 1.57 KB

Contents

class MoveContentViewVersionDescriptionToHistories < ActiveRecord::Migration[4.2]
  class FakeContentViewVersion < ApplicationRecord
    self.table_name = 'katello_content_view_versions'
    has_many :history, :class_name => "CVHistory", :inverse_of => :content_view_version,
                       :dependent => :destroy, :foreign_key => :katello_content_view_version_id
  end

  class CVHistory < ApplicationRecord
    self.table_name = 'katello_content_view_histories'
    belongs_to :content_view_version, :class_name => "FakeContentViewVersion", :foreign_key => :katello_content_view_version_id, :inverse_of => :history
    SUCCESSFUL = 'successful'.freeze
    scope :successful, -> { where(:status => SUCCESSFUL) }

    enum action: {
      publish: 1,
      promotion: 2,
      removal: 3,
      export: 4
    }
  end

  def up
    FakeContentViewVersion.find_each do |version|
      publish_history = version.history.publish.successful.first
      publish_history ||= CVHistory.create!(action: CVHistory.actions[:publish],
                                            katello_content_view_version_id: version.id,
                                            status: 'successful',
                                            user: '',
                                            created_at: version.created_at
                                           )

      publish_history.update_attributes!(notes: version[:description])
    end

    remove_column :katello_content_view_versions, :description, :text
  end

  def down
    add_column :katello_content_view_versions, :description, :text
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
katello-3.9.1 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.10.0.rc1 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.9.0 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.8.1 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.9.0.rc2 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.9.0.rc1 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.7.1.1 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.7.1 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.8.0 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.8.0.rc3 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.8.0.rc2 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.7.0 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.8.0.rc1 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.7.0.rc2 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb
katello-3.7.0.rc1 db/migrate/20161014133811_move_content_view_version_description_to_histories.rb