From 626905fb49c564a08814b445c6e7ae805a5cd237 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 22 May 2015 19:49:25 +0300 Subject: [PATCH] Add certs migration --- db/migrate/20150522164020_update_certs.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 db/migrate/20150522164020_update_certs.rb diff --git a/db/migrate/20150522164020_update_certs.rb b/db/migrate/20150522164020_update_certs.rb new file mode 100644 index 000000000..5b492b271 --- /dev/null +++ b/db/migrate/20150522164020_update_certs.rb @@ -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