mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 09:27:19 +02:00
16 lines
395 B
Ruby
16 lines
395 B
Ruby
class AddCertCommonName < ActiveRecord::Migration
|
|
def self.up
|
|
Certificate.all.each do |x|
|
|
if x.crt.blank? && x.csr.present?
|
|
pc = x.parsed_csr.try(:subject).try(:to_s) || ''
|
|
cn = pc.scan(/\/CN=(.+)/).flatten.first
|
|
x.common_name = cn.split('/').first
|
|
end
|
|
x.save
|
|
end
|
|
end
|
|
|
|
def self.down
|
|
raise ActiveRecord::IrreversibleMigration
|
|
end
|
|
end
|