mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
Registrars import
This commit is contained in:
parent
6b0e155bc1
commit
7cb0a4bdd3
8 changed files with 105 additions and 38 deletions
4
Gemfile
4
Gemfile
|
@ -71,6 +71,9 @@ gem 'depp', github: 'domify/depp', ref: '800ab30dcb6dae33095bcb9df47b4e0a390891a
|
||||||
# gem 'depp', path: '~/projects/depp'
|
# gem 'depp', path: '~/projects/depp'
|
||||||
gem 'epp', '~> 1.4.2', github: 'gitlabeu/epp'
|
gem 'epp', '~> 1.4.2', github: 'gitlabeu/epp'
|
||||||
|
|
||||||
|
# for importing legacy db
|
||||||
|
gem 'activerecord-import', '~> 0.7.0' # for inserting dummy data
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
# dev tools
|
# dev tools
|
||||||
gem 'spring', '~> 1.3.3'
|
gem 'spring', '~> 1.3.3'
|
||||||
|
@ -102,7 +105,6 @@ group :development, :test do
|
||||||
gem 'launchy', '~> 2.4.3' # for opening browser automatically
|
gem 'launchy', '~> 2.4.3' # for opening browser automatically
|
||||||
|
|
||||||
# helper gems
|
# helper gems
|
||||||
gem 'activerecord-import', '~> 0.6.0' # for inserting dummy data
|
|
||||||
gem 'database_cleaner', '~> 1.3.0' # For cleaning db in feature and epp tests
|
gem 'database_cleaner', '~> 1.3.0' # For cleaning db in feature and epp tests
|
||||||
gem 'faker', '~> 1.3.0' # Library to generate fake data
|
gem 'faker', '~> 1.3.0' # Library to generate fake data
|
||||||
|
|
||||||
|
|
65
Gemfile.lock
65
Gemfile.lock
|
@ -79,7 +79,7 @@ GEM
|
||||||
activemodel (= 4.2.1)
|
activemodel (= 4.2.1)
|
||||||
activesupport (= 4.2.1)
|
activesupport (= 4.2.1)
|
||||||
arel (~> 6.0)
|
arel (~> 6.0)
|
||||||
activerecord-import (0.6.0)
|
activerecord-import (0.7.0)
|
||||||
activerecord (>= 3.0)
|
activerecord (>= 3.0)
|
||||||
activesupport (4.2.1)
|
activesupport (4.2.1)
|
||||||
i18n (~> 0.7)
|
i18n (~> 0.7)
|
||||||
|
@ -87,15 +87,15 @@ GEM
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
thread_safe (~> 0.3, >= 0.3.4)
|
thread_safe (~> 0.3, >= 0.3.4)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
addressable (2.3.6)
|
addressable (2.3.8)
|
||||||
akami (1.2.2)
|
akami (1.3.0)
|
||||||
gyoku (>= 0.4.0)
|
gyoku (>= 0.4.0)
|
||||||
nokogiri
|
nokogiri
|
||||||
arel (6.0.0)
|
arel (6.0.0)
|
||||||
ast (2.0.0)
|
ast (2.0.0)
|
||||||
astrolabe (1.3.0)
|
astrolabe (1.3.0)
|
||||||
parser (>= 2.2.0.pre.3, < 3.0)
|
parser (>= 2.2.0.pre.3, < 3.0)
|
||||||
autodoc (0.4.3)
|
autodoc (0.4.4)
|
||||||
actionpack
|
actionpack
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
rspec
|
rspec
|
||||||
|
@ -103,7 +103,7 @@ GEM
|
||||||
descendants_tracker (~> 0.0.4)
|
descendants_tracker (~> 0.0.4)
|
||||||
ice_nine (~> 0.11.0)
|
ice_nine (~> 0.11.0)
|
||||||
thread_safe (~> 0.3, >= 0.3.1)
|
thread_safe (~> 0.3, >= 0.3.1)
|
||||||
bcrypt (3.1.9)
|
bcrypt (3.1.10)
|
||||||
better_errors (2.0.0)
|
better_errors (2.0.0)
|
||||||
coderay (>= 1.0.0)
|
coderay (>= 1.0.0)
|
||||||
erubis (>= 2.6.6)
|
erubis (>= 2.6.6)
|
||||||
|
@ -186,14 +186,14 @@ GEM
|
||||||
epp-xml (0.10.4)
|
epp-xml (0.10.4)
|
||||||
activesupport (~> 4.1)
|
activesupport (~> 4.1)
|
||||||
builder (~> 3.2)
|
builder (~> 3.2)
|
||||||
equalizer (0.0.9)
|
equalizer (0.0.11)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
execjs (2.4.0)
|
execjs (2.4.0)
|
||||||
fabrication (2.12.2)
|
fabrication (2.12.2)
|
||||||
faker (1.3.0)
|
faker (1.3.0)
|
||||||
i18n (~> 0.5)
|
i18n (~> 0.5)
|
||||||
fastercsv (1.5.5)
|
fastercsv (1.5.5)
|
||||||
ffi (1.9.6)
|
ffi (1.9.8)
|
||||||
figaro (1.1.0)
|
figaro (1.1.0)
|
||||||
thor (~> 0.14)
|
thor (~> 0.14)
|
||||||
flay (2.4.0)
|
flay (2.4.0)
|
||||||
|
@ -229,7 +229,7 @@ GEM
|
||||||
guard-rubocop (1.1.0)
|
guard-rubocop (1.1.0)
|
||||||
guard (~> 2.0)
|
guard (~> 2.0)
|
||||||
rubocop (~> 0.20)
|
rubocop (~> 0.20)
|
||||||
gyoku (1.2.3)
|
gyoku (1.3.0)
|
||||||
builder (>= 2.1.2)
|
builder (>= 2.1.2)
|
||||||
haml (4.0.6)
|
haml (4.0.6)
|
||||||
tilt
|
tilt
|
||||||
|
@ -239,22 +239,21 @@ GEM
|
||||||
haml (>= 4.0.6, < 5.0)
|
haml (>= 4.0.6, < 5.0)
|
||||||
html2haml (>= 1.0.1)
|
html2haml (>= 1.0.1)
|
||||||
railties (>= 4.0.1)
|
railties (>= 4.0.1)
|
||||||
hashie (3.3.2)
|
hashie (3.4.1)
|
||||||
hashie_rails (0.0.1)
|
hashie_rails (0.0.4)
|
||||||
hashie (>= 3.0)
|
hashie (>= 3.0)
|
||||||
rails (~> 4.0)
|
|
||||||
highline (1.6.21)
|
highline (1.6.21)
|
||||||
hike (1.2.3)
|
hike (1.2.3)
|
||||||
hitimes (1.2.2)
|
hitimes (1.2.2)
|
||||||
hpricot (0.8.6)
|
hpricot (0.8.6)
|
||||||
httpclient (2.6.0.1)
|
httpclient (2.6.0.1)
|
||||||
httpi (2.3.0)
|
httpi (2.4.0)
|
||||||
rack
|
rack
|
||||||
i18n (0.7.0)
|
i18n (0.7.0)
|
||||||
ice_nine (0.11.1)
|
ice_nine (0.11.1)
|
||||||
isikukood (0.1.2)
|
isikukood (0.1.2)
|
||||||
iso8601 (0.8.2)
|
iso8601 (0.8.5)
|
||||||
jbuilder (2.2.6)
|
jbuilder (2.2.12)
|
||||||
activesupport (>= 3.0.0, < 5)
|
activesupport (>= 3.0.0, < 5)
|
||||||
multi_json (~> 1.2)
|
multi_json (~> 1.2)
|
||||||
jquery-rails (4.0.3)
|
jquery-rails (4.0.3)
|
||||||
|
@ -270,8 +269,8 @@ GEM
|
||||||
addressable (~> 2.3)
|
addressable (~> 2.3)
|
||||||
libv8 (3.16.14.7)
|
libv8 (3.16.14.7)
|
||||||
libxml-ruby (2.8.0)
|
libxml-ruby (2.8.0)
|
||||||
listen (2.8.5)
|
listen (2.10.0)
|
||||||
celluloid (>= 0.15.2)
|
celluloid (~> 0.16.0)
|
||||||
rb-fsevent (>= 0.9.3)
|
rb-fsevent (>= 0.9.3)
|
||||||
rb-inotify (>= 0.9)
|
rb-inotify (>= 0.9)
|
||||||
loofah (2.0.1)
|
loofah (2.0.1)
|
||||||
|
@ -283,7 +282,7 @@ GEM
|
||||||
mime-types (>= 1.16, < 3)
|
mime-types (>= 1.16, < 3)
|
||||||
method_source (0.8.2)
|
method_source (0.8.2)
|
||||||
mime-types (2.4.3)
|
mime-types (2.4.3)
|
||||||
mina (0.3.1)
|
mina (0.3.4)
|
||||||
open4 (~> 1.3.4)
|
open4 (~> 1.3.4)
|
||||||
rake
|
rake
|
||||||
mini_portile (0.6.2)
|
mini_portile (0.6.2)
|
||||||
|
@ -293,11 +292,11 @@ GEM
|
||||||
newrelic_rpm (3.9.9.275)
|
newrelic_rpm (3.9.9.275)
|
||||||
nokogiri (1.6.6.2)
|
nokogiri (1.6.6.2)
|
||||||
mini_portile (~> 0.6.0)
|
mini_portile (~> 0.6.0)
|
||||||
nori (2.4.0)
|
nori (2.5.0)
|
||||||
nprogress-rails (0.1.6.5)
|
nprogress-rails (0.1.6.6)
|
||||||
open4 (1.3.4)
|
open4 (1.3.4)
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
parser (2.2.0.2)
|
parser (2.2.0.3)
|
||||||
ast (>= 1.1, < 3.0)
|
ast (>= 1.1, < 3.0)
|
||||||
pg (0.18.1)
|
pg (0.18.1)
|
||||||
phantomjs (1.9.7.1)
|
phantomjs (1.9.7.1)
|
||||||
|
@ -369,8 +368,8 @@ GEM
|
||||||
sexp_processor
|
sexp_processor
|
||||||
ref (1.0.5)
|
ref (1.0.5)
|
||||||
request_store (1.1.0)
|
request_store (1.1.0)
|
||||||
responders (2.0.2)
|
responders (2.1.0)
|
||||||
railties (>= 4.2.0.alpha, < 5)
|
railties (>= 4.2.0, < 5)
|
||||||
rspec (3.0.0)
|
rspec (3.0.0)
|
||||||
rspec-core (~> 3.0.0)
|
rspec-core (~> 3.0.0)
|
||||||
rspec-expectations (~> 3.0.0)
|
rspec-expectations (~> 3.0.0)
|
||||||
|
@ -397,7 +396,7 @@ GEM
|
||||||
powerpack (~> 0.0.6)
|
powerpack (~> 0.0.6)
|
||||||
rainbow (>= 1.99.1, < 3.0)
|
rainbow (>= 1.99.1, < 3.0)
|
||||||
ruby-progressbar (~> 1.4)
|
ruby-progressbar (~> 1.4)
|
||||||
ruby-progressbar (1.7.1)
|
ruby-progressbar (1.7.5)
|
||||||
ruby2ruby (2.1.3)
|
ruby2ruby (2.1.3)
|
||||||
ruby_parser (~> 3.1)
|
ruby_parser (~> 3.1)
|
||||||
sexp_processor (~> 4.0)
|
sexp_processor (~> 4.0)
|
||||||
|
@ -412,13 +411,13 @@ GEM
|
||||||
virtus (~> 1.0)
|
virtus (~> 1.0)
|
||||||
safe_yaml (1.0.4)
|
safe_yaml (1.0.4)
|
||||||
sass (3.4.13)
|
sass (3.4.13)
|
||||||
sass-rails (5.0.1)
|
sass-rails (5.0.2)
|
||||||
railties (>= 4.0.0, < 5.0)
|
railties (>= 4.0.0, < 5.0)
|
||||||
sass (~> 3.1)
|
sass (~> 3.1)
|
||||||
sprockets (>= 2.8, < 4.0)
|
sprockets (>= 2.8, < 4.0)
|
||||||
sprockets-rails (>= 2.0, < 4.0)
|
sprockets-rails (>= 2.0, < 4.0)
|
||||||
tilt (~> 1.1)
|
tilt (~> 1.1)
|
||||||
savon (2.10.1)
|
savon (2.11.0)
|
||||||
akami (~> 1.2)
|
akami (~> 1.2)
|
||||||
builder (>= 2.1.2)
|
builder (>= 2.1.2)
|
||||||
gyoku (~> 1.2)
|
gyoku (~> 1.2)
|
||||||
|
@ -434,11 +433,11 @@ GEM
|
||||||
sexp_processor (4.5.0)
|
sexp_processor (4.5.0)
|
||||||
shoulda-matchers (2.6.2)
|
shoulda-matchers (2.6.2)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
simplecov (0.9.1)
|
simplecov (0.9.2)
|
||||||
docile (~> 1.1.0)
|
docile (~> 1.1.0)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
simplecov-html (~> 0.8.0)
|
simplecov-html (~> 0.9.0)
|
||||||
simplecov-html (0.8.0)
|
simplecov-html (0.9.0)
|
||||||
simpleidn (0.0.5)
|
simpleidn (0.0.5)
|
||||||
slim (2.1.0)
|
slim (2.1.0)
|
||||||
temple (~> 0.6.9)
|
temple (~> 0.6.9)
|
||||||
|
@ -486,19 +485,19 @@ GEM
|
||||||
uuid (2.3.7)
|
uuid (2.3.7)
|
||||||
macaddr (~> 1.0)
|
macaddr (~> 1.0)
|
||||||
uuidtools (2.1.5)
|
uuidtools (2.1.5)
|
||||||
virtus (1.0.4)
|
virtus (1.0.5)
|
||||||
axiom-types (~> 0.1)
|
axiom-types (~> 0.1)
|
||||||
coercible (~> 1.0)
|
coercible (~> 1.0)
|
||||||
descendants_tracker (~> 0.0, >= 0.0.3)
|
descendants_tracker (~> 0.0, >= 0.0.3)
|
||||||
equalizer (~> 0.0, >= 0.0.9)
|
equalizer (~> 0.0, >= 0.0.9)
|
||||||
warden (1.2.3)
|
warden (1.2.3)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
wasabi (3.4.0)
|
wasabi (3.5.0)
|
||||||
httpi (~> 2.0)
|
httpi (~> 2.0)
|
||||||
nokogiri (>= 1.4.2)
|
nokogiri (>= 1.4.2)
|
||||||
websocket-driver (0.5.1)
|
websocket-driver (0.5.4)
|
||||||
websocket-extensions (>= 0.1.0)
|
websocket-extensions (>= 0.1.0)
|
||||||
websocket-extensions (0.1.1)
|
websocket-extensions (0.1.2)
|
||||||
whenever (0.9.4)
|
whenever (0.9.4)
|
||||||
chronic (>= 0.6.3)
|
chronic (>= 0.6.3)
|
||||||
xpath (2.0.0)
|
xpath (2.0.0)
|
||||||
|
@ -508,7 +507,7 @@ PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
activerecord-import (~> 0.6.0)
|
activerecord-import (~> 0.7.0)
|
||||||
autodoc
|
autodoc
|
||||||
better_errors (~> 2.0.0)
|
better_errors (~> 2.0.0)
|
||||||
binding_of_caller (~> 0.7.2)
|
binding_of_caller (~> 0.7.2)
|
||||||
|
|
10
app/models/legacy/db.rb
Normal file
10
app/models/legacy/db.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
module Legacy
|
||||||
|
class Db < ActiveRecord::Base
|
||||||
|
self.abstract_class = true
|
||||||
|
establish_connection :fred
|
||||||
|
|
||||||
|
def readonly?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
5
app/models/legacy/registrar.rb
Normal file
5
app/models/legacy/registrar.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
module Legacy
|
||||||
|
class Registrar < Db
|
||||||
|
self.table_name = :registrar
|
||||||
|
end
|
||||||
|
end
|
7
db/migrate/20150226121252_remove_country_id_columns.rb
Normal file
7
db/migrate/20150226121252_remove_country_id_columns.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class RemoveCountryIdColumns < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
remove_column :registrars, :country_id, :integer
|
||||||
|
remove_column :users, :country_id, :integer
|
||||||
|
remove_column :addresses, :country_id, :integer
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,8 @@
|
||||||
|
class AddLegacyColumnsForRegistrar < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :registrars, :url, :string
|
||||||
|
add_column :registrars, :directo_handle, :string
|
||||||
|
add_column :registrars, :vat, :boolean
|
||||||
|
add_column :registrars, :legacy_id, :integer
|
||||||
|
end
|
||||||
|
end
|
|
@ -18,7 +18,6 @@ ActiveRecord::Schema.define(version: 20150330083700) do
|
||||||
|
|
||||||
create_table "addresses", force: :cascade do |t|
|
create_table "addresses", force: :cascade do |t|
|
||||||
t.integer "contact_id"
|
t.integer "contact_id"
|
||||||
t.integer "country_id"
|
|
||||||
t.string "city"
|
t.string "city"
|
||||||
t.string "street"
|
t.string "street"
|
||||||
t.string "zip"
|
t.string "zip"
|
||||||
|
@ -579,7 +578,6 @@ ActiveRecord::Schema.define(version: 20150330083700) do
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.string "reg_no"
|
t.string "reg_no"
|
||||||
t.string "vat_no"
|
t.string "vat_no"
|
||||||
t.integer "country_id"
|
|
||||||
t.string "billing_address"
|
t.string "billing_address"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
@ -594,6 +592,10 @@ ActiveRecord::Schema.define(version: 20150330083700) do
|
||||||
t.string "street"
|
t.string "street"
|
||||||
t.string "zip"
|
t.string "zip"
|
||||||
t.string "code"
|
t.string "code"
|
||||||
|
t.string "url"
|
||||||
|
t.string "directo_handle"
|
||||||
|
t.boolean "vat"
|
||||||
|
t.integer "legacy_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "registrars", ["code"], name: "index_registrars_on_code", using: :btree
|
add_index "registrars", ["code"], name: "index_registrars_on_code", using: :btree
|
||||||
|
@ -631,8 +633,6 @@ ActiveRecord::Schema.define(version: 20150330083700) do
|
||||||
t.inet "current_sign_in_ip"
|
t.inet "current_sign_in_ip"
|
||||||
t.inet "last_sign_in_ip"
|
t.inet "last_sign_in_ip"
|
||||||
t.string "identity_code"
|
t.string "identity_code"
|
||||||
t.integer "country_id"
|
|
||||||
t.string "roles", array: true
|
|
||||||
t.string "creator_str"
|
t.string "creator_str"
|
||||||
t.string "updator_str"
|
t.string "updator_str"
|
||||||
t.string "country_code"
|
t.string "country_code"
|
||||||
|
|
36
lib/tasks/import.rake
Normal file
36
lib/tasks/import.rake
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
namespace :import do
|
||||||
|
desc "Imports registrars"
|
||||||
|
task registrars: :environment do
|
||||||
|
puts '-----> Importing registrars...'
|
||||||
|
|
||||||
|
# Registrar.where('legacy_id IS NOT NULL').delete_all
|
||||||
|
|
||||||
|
registrars = []
|
||||||
|
Legacy::Registrar.all.each do |x|
|
||||||
|
next if Registrar.exists?(legacy_id: x.id)
|
||||||
|
|
||||||
|
registrars << Registrar.new({
|
||||||
|
name: x.organization.try(:strip).presence || x.name.try(:strip).presence || x.handle.try(:strip).presence,
|
||||||
|
reg_no: x.ico.try(:strip),
|
||||||
|
vat_no: x.dic.try(:strip),
|
||||||
|
billing_address: nil,
|
||||||
|
phone: x.telephone.try(:strip),
|
||||||
|
email: x.email.try(:strip),
|
||||||
|
billing_email: x.billing_address.try(:strip),
|
||||||
|
country_code: x.country.try(:strip),
|
||||||
|
state: x.stateorprovince.try(:strip),
|
||||||
|
city: x.city.try(:strip),
|
||||||
|
street: x.street1.try(:strip),
|
||||||
|
zip: x.postalcode.try(:strip),
|
||||||
|
url: x.url.try(:strip),
|
||||||
|
directo_handle: x.directo_handle.try(:strip),
|
||||||
|
vat: x.vat,
|
||||||
|
legacy_id: x.id
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
Registrar.import registrars, validate: false
|
||||||
|
|
||||||
|
puts '-----> Registrars imported'
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue