Import tech contacts too

This commit is contained in:
Martin Lensment 2015-03-17 11:50:45 +02:00 committed by Priit Tark
parent d5a7704b87
commit 968e383f9e
6 changed files with 25 additions and 6 deletions

View file

@ -84,7 +84,7 @@ class Contact < ActiveRecord::Base
end end
def to_s def to_s
name name || '[no name]'
end end
def ident_valid_format? def ident_valid_format?

View file

@ -73,9 +73,9 @@ class Dnskey < ActiveRecord::Base
hex = [domain.name_in_wire_format, flags_hex, protocol_hex, alg_hex, public_key_hex].join hex = [domain.name_in_wire_format, flags_hex, protocol_hex, alg_hex, public_key_hex].join
bin = self.class.hex_to_bin(hex) bin = self.class.hex_to_bin(hex)
if Setting.ds_algorithm == 1 if ds_digest_type == 1
self.ds_digest = Digest::SHA1.hexdigest(bin).upcase self.ds_digest = Digest::SHA1.hexdigest(bin).upcase
elsif Setting.ds_algorithm == 2 elsif ds_digest_type == 2
self.ds_digest = Digest::SHA256.hexdigest(bin).upcase self.ds_digest = Digest::SHA256.hexdigest(bin).upcase
end end
end end

View file

@ -10,5 +10,6 @@ module Legacy
has_many :object_states, -> { where('valid_to IS NULL') }, foreign_key: :object_id has_many :object_states, -> { where('valid_to IS NULL') }, foreign_key: :object_id
has_many :dnskeys, foreign_key: :keysetid, primary_key: :keyset has_many :dnskeys, foreign_key: :keysetid, primary_key: :keyset
has_many :domain_contact_maps, foreign_key: :domainid has_many :domain_contact_maps, foreign_key: :domainid
has_many :nsset_contact_maps, foreign_key: :nssetid, primary_key: :nsset
end end
end end

View file

@ -2,6 +2,6 @@ module Legacy
class DomainContactMap < Db class DomainContactMap < Db
self.table_name = :domain_contact_map self.table_name = :domain_contact_map
belongs_to :contact, foreign_key: :contactid, primary_key: :legacy_id, class_name: '::Contact' # belongs_to :contact, foreign_key: :contactid, primary_key: :legacy_id, class_name: '::Contact'
end end
end end

View file

@ -0,0 +1,5 @@
module Legacy
class NssetContactMap < Db
self.table_name = :nsset_contact_map
end
end

View file

@ -164,6 +164,8 @@ namespace :import do
start = Time.now.to_f start = Time.now.to_f
puts '-----> Importing domains...' puts '-----> Importing domains...'
# domain_status_map = {}
domain_columns = [ domain_columns = [
"name", "name",
"registered_at", "registered_at",
@ -255,7 +257,7 @@ namespace :import do
x.registrant x.registrant
] ]
# domain contacts # admin contacts
x.domain_contact_maps.each do |dc| x.domain_contact_maps.each do |dc|
domain_contacts << [ domain_contacts << [
'admin', # TODO: Where to get real contact type? 'admin', # TODO: Where to get real contact type?
@ -266,6 +268,17 @@ namespace :import do
] ]
end end
# tech contacts
x.nsset_contact_maps.each do |dc|
domain_contacts << [
'tech', # TODO: Where to get real contact type?
user,
user,
x.id,
dc.contactid
]
end
# domain statuses # domain statuses
x.object_states.each do |state| x.object_states.each do |state|
domain_statuses << [ domain_statuses << [
@ -304,7 +317,7 @@ namespace :import do
key.alg, key.alg,
key.key, key.key,
3, # ds_alg 3, # ds_alg
Setting.ds_algorithm, # ds_digest_type 1, # ds_digest_type /SHA1)
user, user,
user, user,
x.id x.id