Sha256: c777fd89b1dea0477ff149a05883d0e918385f6513c5c1ddf07f7bae49348ba4

Contents?: true

Size: 623 Bytes

Versions: 16

Compression:

Stored size: 623 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 < ActiveRecord::Base
    self.table_name = 'scaptimony_scap_contents'
    def digest
      self[:digest] ||= Digest::SHA256.hexdigest scap_file.to_s
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
foreman_openscap-0.7.13 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.7.12 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.7.11 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.7.10 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.8.3 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.7.9 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.7.8 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.7.7 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.8.2 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.7.6 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.8.1 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.7.5 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.8.0 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.7.4 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.7.3 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb
foreman_openscap-0.7.2 db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb