Add certs migration

This commit is contained in:
Martin Lensment 2015-05-22 19:49:25 +03:00
parent 624f69003b
commit 626905fb49

View file

@ -0,0 +1,15 @@
class UpdateCerts < ActiveRecord::Migration
def change
Certificate.all.each do |x|
if x.crt.present? && x.csr.present?
x.interface = Certificate::REGISTRAR
x.md5 = OpenSSL::Digest::MD5.new(x.parsed_crt.to_der).to_s
elsif x.crt.present? && x.csr.blank?
x.interface = Certificate::API
x.md5 = OpenSSL::Digest::MD5.new(x.parsed_crt.to_der).to_s
elsif x.crt.blank? && x.csr.present?
x.interface = Certificate::REGISTRAR
end
end
end
end