Sha256: 3040a1858b7d804a950b3bf127aa55d4808a4b079c8c5f0694fd8863ba1e0038

Contents?: true

Size: 622 Bytes

Versions: 3

Compression:

Stored size: 622 Bytes

Contents

require 'digest/sha2'

class AddScaptimonyScapContentDigest < ActiveRecord::Migration
  def change
    unless column_exists?(:scaptimony_scap_contents, :digest)
      add_column :scaptimony_scap_contents, :digest, :string, :limit => 128
      ScapContentHack.find_each do |content|
        content.digest
        content.save!
      end
      change_column :scaptimony_scap_contents, :digest, :string, :null => false
    end
  end

  class ScapContentHack < ApplicationRecord
    self.table_name = 'scaptimony_scap_contents'
    def digest
      self[:digest] ||= Digest::SHA256.hexdigest scap_file.to_s
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_openscap-0.8.6 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.8.5 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.8.4 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb