diff --git a/app/models/legacy/contact.rb b/app/models/legacy/contact.rb new file mode 100644 index 000000000..64da7c886 --- /dev/null +++ b/app/models/legacy/contact.rb @@ -0,0 +1,5 @@ +module Legacy + class Contact < Db + self.table_name = :contact + end +end diff --git a/app/models/legacy/object_registry.rb b/app/models/legacy/object_registry.rb new file mode 100644 index 000000000..bb0f003e4 --- /dev/null +++ b/app/models/legacy/object_registry.rb @@ -0,0 +1,6 @@ +module Legacy + class ObjectRegistry < Db + self.table_name = :object_registry + self.inheritance_column = nil + end +end diff --git a/db/migrate/20150227092508_add_legacy_columns_for_contact.rb b/db/migrate/20150227092508_add_legacy_columns_for_contact.rb new file mode 100644 index 000000000..0aba53c38 --- /dev/null +++ b/db/migrate/20150227092508_add_legacy_columns_for_contact.rb @@ -0,0 +1,5 @@ +class AddLegacyColumnsForContact < ActiveRecord::Migration + def change + add_column :contacts, :legacy_id, :integer + end +end diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 426c41939..754f1b708 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -1,9 +1,9 @@ namespace :import do - desc "Imports registrars" + desc 'Imports registrars' task registrars: :environment do puts '-----> Importing registrars...' - # Registrar.where('legacy_id IS NOT NULL').delete_all + Registrar.where('legacy_id IS NOT NULL').delete_all registrars = [] existing_ids = Registrar.pluck(:legacy_id) @@ -27,7 +27,9 @@ namespace :import do url: x.url.try(:strip), directo_handle: x.directo_handle.try(:strip), vat: x.vat, - legacy_id: x.id + legacy_id: x.id, + creator_str: "rake-#{`whoami`.strip} #{ARGV.join ' '}", + updator_str: "rake-#{`whoami`.strip} #{ARGV.join ' '}" }) end @@ -35,4 +37,46 @@ namespace :import do puts '-----> Registrars imported' end + + # desc 'Import contacts' + # task contact: :environment do + # puts '-----> Importing contacts...' + + # contacts = [] + # existing_ids = Contact.pluck(:legacy_id) + + # Legacy::Contact.all.each do |x| + # next if existing_ids.include?(x.id) + + # 1;"RC";"born number" + # 2;"OP";"identity card number" -> priv + # 3;"PASS";"passwport" -> + # 4;"ICO";"organization identification number" + # 5;"MPSV";"social system identification" + # 6;"BIRTHDAY";"day of birth" + + # contacts << Contact.new({ + # code: , + # #type: , # not needed + # #reg_no: x.ssn.try(:strip), + # phone: x.telephone.try(:strip), + # email: x.email.try(:strip), + # fax: x.fax.try(:strip), + # ident: x.ssn.try(:strip), + # ident_type: , + # #created_by_id: , # not needed + # #updated_by_id: , # not needed + # auth_info: , + # name: x.name.try(:strip), + # org_name: x.organization.try(:strip), + # registrar_id: , + # creator_str: "rake-#{`whoami`.strip} #{ARGV.join ' '}", + # updator_str: "rake-#{`whoami`.strip} #{ARGV.join ' '}" + # ident_country_code: x.country.try(:strip), + # legacy_id: x.id + # }) + # end + + # puts '-----> Contacts imported' + # end end