Address depricated, new contact requires, domain_contacts refactor

This commit is contained in:
Priit Tark 2015-03-31 15:15:19 +03:00
parent 0e252b0b6b
commit 5fd73b037a
38 changed files with 402 additions and 501 deletions

View file

@ -0,0 +1,5 @@
class AddDomainContactType < ActiveRecord::Migration
def change
add_column :domain_contacts, :type, :string
end
end

View file

@ -0,0 +1,17 @@
class UpdateDomainContactData < ActiveRecord::Migration
def change
DomainContact.all.each do |dc|
case dc.contact_type
when 'admin'
dc.type = 'AdminDomainContact'
when 'tech'
dc.type = 'TechDomainContact'
end
if dc.changes.present?
puts "Changed: #{dc.id}: #{dc.changes.inspect} #{dc.save}"
else
puts "No changes: #{dc.id}"
end
end
end
end

View file

@ -0,0 +1,9 @@
class AddAddressAttributes < ActiveRecord::Migration
def change
add_column :contacts, :city, :string
add_column :contacts, :street, :text
add_column :contacts, :zip, :string
add_column :contacts, :country_code, :string
add_column :contacts, :state, :string
end
end

View file

@ -0,0 +1,16 @@
class UpdateContactData < ActiveRecord::Migration
def change
Address.all.each do |a|
c = a.contact
c.city = a.city
c.street = ""
c.street << a.street if a.street.present?
c.street << "\n#{a.street2}" if a.street2.present?
c.street << "\n#{a.street3}" if a.street3.present?
c.zip = a.zip
c.country_code = a.country_code
c.state = a.state
puts "#{c.id} changes: #{c.changes.inspect}; #{c.save(false)}"
end
end
end

View file

@ -0,0 +1,6 @@
class DepricateContactDisclouserTable < ActiveRecord::Migration
def change
drop_table :contact_disclosures
drop_table :log_contact_disclosures
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150320132023) do
ActiveRecord::Schema.define(version: 20150330083700) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -63,20 +63,6 @@ ActiveRecord::Schema.define(version: 20150320132023) do
t.datetime "updated_at"
end
create_table "contact_disclosures", force: :cascade do |t|
t.integer "contact_id"
t.boolean "phone"
t.boolean "fax"
t.boolean "email"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "name"
t.boolean "org_name"
t.boolean "address"
t.string "creator_str"
t.string "updator_str"
end
create_table "contact_statuses", force: :cascade do |t|
t.string "value"
t.string "description"
@ -107,6 +93,11 @@ ActiveRecord::Schema.define(version: 20150320132023) do
t.string "creator_str"
t.string "updator_str"
t.string "ident_country_code"
t.string "city"
t.text "street"
t.string "zip"
t.string "country_code"
t.string "state"
end
add_index "contacts", ["code"], name: "index_contacts_on_code", using: :btree
@ -172,6 +163,7 @@ ActiveRecord::Schema.define(version: 20150320132023) do
t.string "contact_code_cache"
t.string "creator_str"
t.string "updator_str"
t.string "type"
end
create_table "domain_statuses", force: :cascade do |t|
@ -302,21 +294,6 @@ ActiveRecord::Schema.define(version: 20150320132023) do
t.json "children"
end
create_table "log_contact_disclosures", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_contact_disclosures", ["item_type", "item_id"], name: "index_log_contact_disclosures_on_item_type_and_item_id", using: :btree
add_index "log_contact_disclosures", ["whodunnit"], name: "index_log_contact_disclosures_on_whodunnit", using: :btree
create_table "log_contact_statuses", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false