addresses 1.0.11 → 2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/addresses/application_controller.rb +2 -0
  3. data/app/controllers/addresses/cities_controller.rb +3 -1
  4. data/app/controllers/addresses/neighborhoods_controller.rb +4 -2
  5. data/app/controllers/addresses/states_controller.rb +5 -5
  6. data/app/controllers/addresses/zipcodes_controller.rb +7 -5
  7. data/app/models/addresses/address.rb +5 -2
  8. data/app/models/addresses/city.rb +5 -1
  9. data/app/models/addresses/country.rb +3 -0
  10. data/app/models/addresses/neighborhood.rb +4 -0
  11. data/app/models/addresses/state.rb +4 -0
  12. data/app/models/addresses/zipcode.rb +11 -39
  13. data/config/routes.rb +2 -0
  14. data/db/migrate/20140327141509_create_addresses_countries.rb +2 -1
  15. data/db/migrate/20140327163801_create_addresses_states.rb +2 -1
  16. data/db/migrate/20140327171527_create_addresses_cities.rb +2 -1
  17. data/db/migrate/20140327190411_create_addresses_neighborhoods.rb +2 -1
  18. data/db/migrate/20140328120418_create_addresses_addresses.rb +3 -1
  19. data/db/migrate/20160920172944_create_addresses_zipcodes.rb +2 -0
  20. data/db/migrate/20160920174406_remove_zipcode_attributes_from_addresses.rb +2 -0
  21. data/db/migrate/20191008052817_add_indexes.rb +21 -0
  22. data/lib/addresses.rb +3 -1
  23. data/lib/addresses/engine.rb +4 -2
  24. data/lib/tasks/addresses_tasks.rake +6 -6
  25. data/lib/tasks/populate/br/cities.rake +5573 -0
  26. data/lib/tasks/populate/br/countries.rake +247 -0
  27. data/lib/tasks/populate/br/neighborhoods.rake +40825 -0
  28. data/lib/tasks/populate/br/states.rake +35 -0
  29. data/lib/tasks/populate/br/zipcodes.rake +40 -0
  30. data/spec/controllers/addresses/cities_controller_spec.rb +1 -1
  31. data/spec/controllers/addresses/neighborhoods_controller_spec.rb +1 -1
  32. data/spec/controllers/addresses/states_controller_spec.rb +1 -1
  33. data/spec/controllers/addresses/zipcodes_controller_spec.rb +1 -1
  34. data/spec/dummy/Gemfile +1 -1
  35. data/spec/dummy/Gemfile.lock +107 -84
  36. data/spec/dummy/config/application.rb +1 -1
  37. data/spec/dummy/db/development.sqlite3 +0 -0
  38. data/spec/dummy/db/migrate/{20190614190958_create_addresses_countries.addresses.rb → 20191008054118_create_addresses_countries.addresses.rb} +1 -0
  39. data/spec/dummy/db/migrate/{20190614190959_create_addresses_states.addresses.rb → 20191008054119_create_addresses_states.addresses.rb} +1 -0
  40. data/spec/dummy/db/migrate/{20190614190960_create_addresses_cities.addresses.rb → 20191008054120_create_addresses_cities.addresses.rb} +1 -0
  41. data/spec/dummy/db/migrate/{20190614190961_create_addresses_neighborhoods.addresses.rb → 20191008054121_create_addresses_neighborhoods.addresses.rb} +1 -0
  42. data/spec/dummy/db/migrate/{20190614190962_create_addresses_addresses.addresses.rb → 20191008054122_create_addresses_addresses.addresses.rb} +2 -0
  43. data/spec/dummy/db/migrate/{20190614190963_create_addresses_zipcodes.addresses.rb → 20191008054123_create_addresses_zipcodes.addresses.rb} +2 -0
  44. data/spec/dummy/db/migrate/{20190614190964_remove_zipcode_attributes_from_addresses.addresses.rb → 20191008054124_remove_zipcode_attributes_from_addresses.addresses.rb} +2 -0
  45. data/spec/dummy/db/migrate/20191008054125_add_indexes.addresses.rb +22 -0
  46. data/spec/dummy/db/schema.rb +36 -26
  47. data/spec/dummy/db/test.sqlite3 +0 -0
  48. data/spec/dummy/log/development.log +463 -0
  49. data/spec/dummy/log/test.log +9374 -0
  50. data/spec/factories/addresses.rb +3 -3
  51. data/spec/factories/cities.rb +2 -2
  52. data/spec/factories/countries.rb +3 -3
  53. data/spec/factories/neighborhoods.rb +2 -2
  54. data/spec/factories/states.rb +3 -3
  55. data/spec/factories/zipcodes.rb +3 -3
  56. data/spec/fixtures/zipcodes/br/ceps.txt +0 -0
  57. data/spec/models/addresses/address_spec.rb +3 -3
  58. data/spec/models/addresses/city_spec.rb +1 -1
  59. data/spec/models/addresses/country_spec.rb +1 -1
  60. data/spec/models/addresses/neighborhood_spec.rb +1 -1
  61. data/spec/models/addresses/state_spec.rb +1 -1
  62. data/spec/models/addresses/zipcode_spec.rb +1 -30
  63. data/spec/{spec_helper.rb → rails_helper.rb} +3 -4
  64. data/spec/requests/cities_spec.rb +1 -1
  65. data/spec/requests/neighborhoods_spec.rb +1 -1
  66. data/spec/requests/zipcodes_spec.rb +11 -5
  67. data/spec/routing/cities_routing_spec.rb +1 -1
  68. data/spec/routing/neighborhoods_routing_spec.rb +1 -1
  69. data/spec/routing/zipcodes_routing_spec.rb +1 -1
  70. metadata +42 -54
  71. data/README.rdoc +0 -55
  72. data/app/assets/javascripts/addresses/application.js +0 -13
  73. data/app/assets/stylesheets/addresses/application.css +0 -13
  74. data/app/helpers/addresses/application_helper.rb +0 -4
  75. data/app/services/zipcode_service.rb +0 -42
  76. data/lib/tasks/natal_city.rake +0 -50
  77. data/lib/tasks/populate_cities.rake +0 -5570
  78. data/lib/tasks/populate_countries.rake +0 -243
  79. data/lib/tasks/populate_neighborhoods.rake +0 -40823
  80. data/lib/tasks/populate_states.rake +0 -32
  81. data/spec/dummy/db/migrate/20190614190716_create_addresses_countries.addresses.rb +0 -13
  82. data/spec/services/zipcode_service_spec.rb +0 -29
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ namespace :br do
4
+ desc 'Populate Brazilian States'
5
+ task states: [:environment] do
6
+ puts 'Populating States'
7
+ Addresses::State.find_or_create_by(id: '28', name: 'Acre', acronym: 'AC', country_id: 33)
8
+ Addresses::State.find_or_create_by(id: '29', name: 'Alagoas', acronym: 'AL', country_id: 33)
9
+ Addresses::State.find_or_create_by(id: '30', name: 'Amazonas', acronym: 'AM', country_id: 33)
10
+ Addresses::State.find_or_create_by(id: '31', name: 'Amapá', acronym: 'AP', country_id: 33)
11
+ Addresses::State.find_or_create_by(id: '32', name: 'Bahia', acronym: 'BA', country_id: 33)
12
+ Addresses::State.find_or_create_by(id: '33', name: 'Ceará', acronym: 'CE', country_id: 33)
13
+ Addresses::State.find_or_create_by(id: '34', name: 'Brasília', acronym: 'DF', country_id: 33)
14
+ Addresses::State.find_or_create_by(id: '35', name: 'Espírito Santo', acronym: 'ES', country_id: 33)
15
+ Addresses::State.find_or_create_by(id: '36', name: 'Goiás', acronym: 'GO', country_id: 33)
16
+ Addresses::State.find_or_create_by(id: '37', name: 'Maranhão', acronym: 'MA', country_id: 33)
17
+ Addresses::State.find_or_create_by(id: '38', name: 'Minas Gerais', acronym: 'MG', country_id: 33)
18
+ Addresses::State.find_or_create_by(id: '39', name: 'Mato Grosso do Sul', acronym: 'MS', country_id: 33)
19
+ Addresses::State.find_or_create_by(id: '40', name: 'Mato Grosso', acronym: 'MT', country_id: 33)
20
+ Addresses::State.find_or_create_by(id: '41', name: 'Pará', acronym: 'PA', country_id: 33)
21
+ Addresses::State.find_or_create_by(id: '42', name: 'Paraíba', acronym: 'PB', country_id: 33)
22
+ Addresses::State.find_or_create_by(id: '43', name: 'Pernambuco', acronym: 'PE', country_id: 33)
23
+ Addresses::State.find_or_create_by(id: '44', name: 'Piauí', acronym: 'PI', country_id: 33)
24
+ Addresses::State.find_or_create_by(id: '45', name: 'Paraná', acronym: 'PR', country_id: 33)
25
+ Addresses::State.find_or_create_by(id: '46', name: 'Rio de Janeiro', acronym: 'RJ', country_id: 33)
26
+ Addresses::State.find_or_create_by(id: '47', name: 'Rio Grande do Norte', acronym: 'RN', country_id: 33)
27
+ Addresses::State.find_or_create_by(id: '48', name: 'Rondônia', acronym: 'RO', country_id: 33)
28
+ Addresses::State.find_or_create_by(id: '49', name: 'Roraima', acronym: 'RR', country_id: 33)
29
+ Addresses::State.find_or_create_by(id: '50', name: 'Rio Grande do Sul', acronym: 'RS', country_id: 33)
30
+ Addresses::State.find_or_create_by(id: '51', name: 'Santa Catarina', acronym: 'SC', country_id: 33)
31
+ Addresses::State.find_or_create_by(id: '52', name: 'Sergipe', acronym: 'SE', country_id: 33)
32
+ Addresses::State.find_or_create_by(id: '53', name: 'São Paulo', acronym: 'SP', country_id: 33)
33
+ Addresses::State.find_or_create_by(id: '54', name: 'Tocantins', acronym: 'TO', country_id: 33)
34
+ end
35
+ end
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ namespace :populate do
4
+ namespace :br do
5
+ desc 'Populate Brazilian Zipcodes'
6
+ task zipcodes: [:environment] do
7
+ puts 'Populating Zipcodes'
8
+ File.readlines("#{Addresses::Engine.root}/fixtures/zipcodes/br/ceps.txt").each do |line|
9
+ zipcode_number, city_state, neighborhood_name, street_name = line.split(/\t/)
10
+
11
+ city_name = city_state.strip.split('/')[0]
12
+ state_acronym = city_state.split('/')[1][0..1]
13
+
14
+ next unless Addresses::Zipcode.find_by(number: zipcode_number.strip).nil?
15
+
16
+ state = Addresses::State.find_by(acronym: state_acronym)
17
+
18
+ city = state.cities.find_or_create_by(name: city_name)
19
+
20
+ unless neighborhood_name.blank?
21
+ neighborhood = city.neighborhoods.find_by(name: neighborhood_name.strip)
22
+ neighborhood = city.neighborhoods.create!(name: neighborhood_name) if neighborhood.nil?
23
+ end
24
+
25
+ zipcode = Addresses::Zipcode.new
26
+ zipcode.city_id = city.id
27
+ zipcode.neighborhood_id = neighborhood.try(:id)
28
+ zipcode.street = street_name.strip
29
+ zipcode.number = zipcode_number.strip
30
+
31
+ if zipcode.valid?
32
+ zipcode.save!
33
+ else
34
+ puts "#{zipcode.inspect} invalid"
35
+ next
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rails_helper'
3
3
 
4
4
  RSpec.describe Addresses::CitiesController, type: :controller do
5
5
  routes { Addresses::Engine.routes }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rails_helper'
3
3
 
4
4
  RSpec.describe Addresses::NeighborhoodsController, type: :controller do
5
5
  routes { Addresses::Engine.routes }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rails_helper'
3
3
 
4
4
  RSpec.describe Addresses::StatesController, type: :controller do
5
5
  routes { Addresses::Engine.routes }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rails_helper'
3
3
 
4
4
  RSpec.describe Addresses::ZipcodesController, type: :controller do
5
5
  routes { Addresses::Engine.routes }
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gem 'sqlite3'
4
- gem 'addresses', path: '../../../addresses'
4
+ gem 'addresses', path: '../../../addresses'
@@ -1,113 +1,136 @@
1
1
  PATH
2
- remote: ../../../addresses
2
+ remote: ../..
3
3
  specs:
4
- addresses (1.0.3)
5
- rails (~> 5.0)
4
+ addresses (2.0)
5
+ rails (~> 6.0.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (5.0.0.1)
11
- actionpack (= 5.0.0.1)
12
- nio4r (~> 1.2)
13
- websocket-driver (~> 0.6.1)
14
- actionmailer (5.0.0.1)
15
- actionpack (= 5.0.0.1)
16
- actionview (= 5.0.0.1)
17
- activejob (= 5.0.0.1)
10
+ actioncable (6.0.0)
11
+ actionpack (= 6.0.0)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (6.0.0)
15
+ actionpack (= 6.0.0)
16
+ activejob (= 6.0.0)
17
+ activerecord (= 6.0.0)
18
+ activestorage (= 6.0.0)
19
+ activesupport (= 6.0.0)
20
+ mail (>= 2.7.1)
21
+ actionmailer (6.0.0)
22
+ actionpack (= 6.0.0)
23
+ actionview (= 6.0.0)
24
+ activejob (= 6.0.0)
18
25
  mail (~> 2.5, >= 2.5.4)
19
26
  rails-dom-testing (~> 2.0)
20
- actionpack (5.0.0.1)
21
- actionview (= 5.0.0.1)
22
- activesupport (= 5.0.0.1)
27
+ actionpack (6.0.0)
28
+ actionview (= 6.0.0)
29
+ activesupport (= 6.0.0)
23
30
  rack (~> 2.0)
24
- rack-test (~> 0.6.3)
31
+ rack-test (>= 0.6.3)
25
32
  rails-dom-testing (~> 2.0)
26
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.0.0.1)
28
- activesupport (= 5.0.0.1)
33
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
+ actiontext (6.0.0)
35
+ actionpack (= 6.0.0)
36
+ activerecord (= 6.0.0)
37
+ activestorage (= 6.0.0)
38
+ activesupport (= 6.0.0)
39
+ nokogiri (>= 1.8.5)
40
+ actionview (6.0.0)
41
+ activesupport (= 6.0.0)
29
42
  builder (~> 3.1)
30
- erubis (~> 2.7.0)
43
+ erubi (~> 1.4)
31
44
  rails-dom-testing (~> 2.0)
32
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
33
- activejob (5.0.0.1)
34
- activesupport (= 5.0.0.1)
45
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
+ activejob (6.0.0)
47
+ activesupport (= 6.0.0)
35
48
  globalid (>= 0.3.6)
36
- activemodel (5.0.0.1)
37
- activesupport (= 5.0.0.1)
38
- activerecord (5.0.0.1)
39
- activemodel (= 5.0.0.1)
40
- activesupport (= 5.0.0.1)
41
- arel (~> 7.0)
42
- activesupport (5.0.0.1)
49
+ activemodel (6.0.0)
50
+ activesupport (= 6.0.0)
51
+ activerecord (6.0.0)
52
+ activemodel (= 6.0.0)
53
+ activesupport (= 6.0.0)
54
+ activestorage (6.0.0)
55
+ actionpack (= 6.0.0)
56
+ activejob (= 6.0.0)
57
+ activerecord (= 6.0.0)
58
+ marcel (~> 0.3.1)
59
+ activesupport (6.0.0)
43
60
  concurrent-ruby (~> 1.0, >= 1.0.2)
44
- i18n (~> 0.7)
61
+ i18n (>= 0.7, < 2)
45
62
  minitest (~> 5.1)
46
63
  tzinfo (~> 1.1)
47
- arel (7.1.2)
48
- builder (3.2.2)
49
- concurrent-ruby (1.0.2)
50
- erubis (2.7.0)
51
- globalid (0.3.7)
52
- activesupport (>= 4.1.0)
53
- i18n (0.7.0)
54
- loofah (2.0.3)
64
+ zeitwerk (~> 2.1, >= 2.1.8)
65
+ builder (3.2.3)
66
+ concurrent-ruby (1.1.5)
67
+ crass (1.0.4)
68
+ erubi (1.9.0)
69
+ globalid (0.4.2)
70
+ activesupport (>= 4.2.0)
71
+ i18n (1.7.0)
72
+ concurrent-ruby (~> 1.0)
73
+ loofah (2.3.0)
74
+ crass (~> 1.0.2)
55
75
  nokogiri (>= 1.5.9)
56
- mail (2.6.4)
57
- mime-types (>= 1.16, < 4)
58
- method_source (0.8.2)
59
- mime-types (3.1)
60
- mime-types-data (~> 3.2015)
61
- mime-types-data (3.2016.0521)
62
- mini_portile2 (2.1.0)
63
- minitest (5.9.0)
64
- nio4r (1.2.1)
65
- nokogiri (1.6.8)
66
- mini_portile2 (~> 2.1.0)
67
- pkg-config (~> 1.1.7)
68
- pkg-config (1.1.7)
69
- rack (2.0.1)
70
- rack-test (0.6.3)
71
- rack (>= 1.0)
72
- rails (5.0.0.1)
73
- actioncable (= 5.0.0.1)
74
- actionmailer (= 5.0.0.1)
75
- actionpack (= 5.0.0.1)
76
- actionview (= 5.0.0.1)
77
- activejob (= 5.0.0.1)
78
- activemodel (= 5.0.0.1)
79
- activerecord (= 5.0.0.1)
80
- activesupport (= 5.0.0.1)
81
- bundler (>= 1.3.0, < 2.0)
82
- railties (= 5.0.0.1)
76
+ mail (2.7.1)
77
+ mini_mime (>= 0.1.1)
78
+ marcel (0.3.3)
79
+ mimemagic (~> 0.3.2)
80
+ method_source (0.9.2)
81
+ mimemagic (0.3.3)
82
+ mini_mime (1.0.2)
83
+ mini_portile2 (2.4.0)
84
+ minitest (5.12.2)
85
+ nio4r (2.5.2)
86
+ nokogiri (1.10.4)
87
+ mini_portile2 (~> 2.4.0)
88
+ rack (2.0.7)
89
+ rack-test (1.1.0)
90
+ rack (>= 1.0, < 3)
91
+ rails (6.0.0)
92
+ actioncable (= 6.0.0)
93
+ actionmailbox (= 6.0.0)
94
+ actionmailer (= 6.0.0)
95
+ actionpack (= 6.0.0)
96
+ actiontext (= 6.0.0)
97
+ actionview (= 6.0.0)
98
+ activejob (= 6.0.0)
99
+ activemodel (= 6.0.0)
100
+ activerecord (= 6.0.0)
101
+ activestorage (= 6.0.0)
102
+ activesupport (= 6.0.0)
103
+ bundler (>= 1.3.0)
104
+ railties (= 6.0.0)
83
105
  sprockets-rails (>= 2.0.0)
84
- rails-dom-testing (2.0.1)
85
- activesupport (>= 4.2.0, < 6.0)
86
- nokogiri (~> 1.6.0)
87
- rails-html-sanitizer (1.0.3)
88
- loofah (~> 2.0)
89
- railties (5.0.0.1)
90
- actionpack (= 5.0.0.1)
91
- activesupport (= 5.0.0.1)
106
+ rails-dom-testing (2.0.3)
107
+ activesupport (>= 4.2.0)
108
+ nokogiri (>= 1.6)
109
+ rails-html-sanitizer (1.3.0)
110
+ loofah (~> 2.3)
111
+ railties (6.0.0)
112
+ actionpack (= 6.0.0)
113
+ activesupport (= 6.0.0)
92
114
  method_source
93
115
  rake (>= 0.8.7)
94
- thor (>= 0.18.1, < 2.0)
95
- rake (11.2.2)
96
- sprockets (3.7.0)
116
+ thor (>= 0.20.3, < 2.0)
117
+ rake (13.0.0)
118
+ sprockets (3.7.2)
97
119
  concurrent-ruby (~> 1.0)
98
120
  rack (> 1, < 3)
99
- sprockets-rails (3.2.0)
121
+ sprockets-rails (3.2.1)
100
122
  actionpack (>= 4.0)
101
123
  activesupport (>= 4.0)
102
124
  sprockets (>= 3.0.0)
103
- sqlite3 (1.3.11)
104
- thor (0.19.1)
105
- thread_safe (0.3.5)
106
- tzinfo (1.2.2)
125
+ sqlite3 (1.4.1)
126
+ thor (0.20.3)
127
+ thread_safe (0.3.6)
128
+ tzinfo (1.2.5)
107
129
  thread_safe (~> 0.1)
108
- websocket-driver (0.6.4)
130
+ websocket-driver (0.7.1)
109
131
  websocket-extensions (>= 0.1.0)
110
- websocket-extensions (0.1.2)
132
+ websocket-extensions (0.1.4)
133
+ zeitwerk (2.1.10)
111
134
 
112
135
  PLATFORMS
113
136
  ruby
@@ -117,4 +140,4 @@ DEPENDENCIES
117
140
  sqlite3
118
141
 
119
142
  BUNDLED WITH
120
- 1.13.0
143
+ 1.17.3
@@ -3,6 +3,7 @@ require File.expand_path('../boot', __FILE__)
3
3
  require 'rails/all'
4
4
 
5
5
  Bundler.require(*Rails.groups)
6
+
6
7
  require "addresses"
7
8
 
8
9
  module Dummy
@@ -24,4 +25,3 @@ module Dummy
24
25
  # Store::Engine.config.18n.default_locale = config.i18n.default_locale
25
26
  end
26
27
  end
27
-
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  # This migration comes from addresses (originally 20140327141509)
3
4
 
4
5
  class CreateAddressesCountries < ActiveRecord::Migration[4.2]
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  # This migration comes from addresses (originally 20140327163801)
3
4
 
4
5
  class CreateAddressesStates < ActiveRecord::Migration[4.2]
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  # This migration comes from addresses (originally 20140327171527)
3
4
 
4
5
  class CreateAddressesCities < ActiveRecord::Migration[4.2]
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  # This migration comes from addresses (originally 20140327190411)
3
4
 
4
5
  class CreateAddressesNeighborhoods < ActiveRecord::Migration[4.2]
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  # This migration comes from addresses (originally 20140328120418)
3
+
2
4
  class CreateAddressesAddresses < ActiveRecord::Migration[4.2]
3
5
  def change
4
6
  create_table :addresses_addresses do |t|
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  # This migration comes from addresses (originally 20160920172944)
3
+
2
4
  class CreateAddressesZipcodes < ActiveRecord::Migration[5.0]
3
5
  def change
4
6
  create_table :addresses_zipcodes do |t|
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  # This migration comes from addresses (originally 20160920174406)
3
+
2
4
  class RemoveZipcodeAttributesFromAddresses < ActiveRecord::Migration[5.0]
3
5
  def change
4
6
  remove_column :addresses_addresses, :street, :string
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ # This migration comes from addresses (originally 20191008052817)
3
+
4
+ class AddIndexes < ActiveRecord::Migration[6.0]
5
+ def change
6
+ add_index :addresses_neighborhoods, :name
7
+ add_index :addresses_neighborhoods, [:name, :city_id]
8
+
9
+ add_index :addresses_countries, :name
10
+ add_index :addresses_countries, :acronym
11
+
12
+ add_index :addresses_cities, :name
13
+ add_index :addresses_cities, [:name, :state_id]
14
+
15
+ add_index :addresses_states, :name
16
+ add_index :addresses_states, [:name, :country_id]
17
+
18
+ add_index :addresses_zipcodes, :number
19
+
20
+ add_index :addresses_addresses, [:addressable_id, :addressable_type], name: :index_addresses_addressable
21
+ end
22
+ end
@@ -2,69 +2,79 @@
2
2
  # of editing this file, please use the migrations feature of Active Record to
3
3
  # incrementally modify your database, and then regenerate this schema definition.
4
4
  #
5
- # Note that this schema.rb definition is the authoritative source for your
6
- # database schema. If you need to create the application database on another
7
- # system, you should be using db:schema:load, not running all the migrations
8
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
- # you'll amass, the slower it'll run and the greater likelihood for issues).
5
+ # This file is the source Rails uses to define your schema when running `rails
6
+ # db:schema:load`. When creating a new database, `rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 20160920174406) do
13
+ ActiveRecord::Schema.define(version: 2019_10_08_054125) do
14
14
 
15
15
  create_table "addresses_addresses", force: :cascade do |t|
16
- t.string "number"
17
- t.string "complement"
18
- t.integer "addressable_id"
19
- t.string "addressable_type"
16
+ t.string "number"
17
+ t.string "complement"
18
+ t.integer "addressable_id"
19
+ t.string "addressable_type"
20
20
  t.datetime "created_at"
21
21
  t.datetime "updated_at"
22
- t.integer "zipcode_id"
22
+ t.integer "zipcode_id"
23
+ t.index ["addressable_id", "addressable_type"], name: "index_addresses_addressable"
23
24
  t.index ["addressable_id"], name: "index_addresses_addresses_on_addressable_id"
24
25
  t.index ["zipcode_id"], name: "index_addresses_addresses_on_zipcode_id"
25
26
  end
26
27
 
27
28
  create_table "addresses_cities", force: :cascade do |t|
28
- t.string "name"
29
- t.integer "state_id"
29
+ t.string "name"
30
+ t.integer "state_id"
30
31
  t.datetime "created_at"
31
32
  t.datetime "updated_at"
33
+ t.index ["name", "state_id"], name: "index_addresses_cities_on_name_and_state_id"
34
+ t.index ["name"], name: "index_addresses_cities_on_name"
32
35
  t.index ["state_id"], name: "index_addresses_cities_on_state_id"
33
36
  end
34
37
 
35
38
  create_table "addresses_countries", force: :cascade do |t|
36
- t.string "name"
37
- t.string "acronym"
39
+ t.string "name"
40
+ t.string "acronym"
38
41
  t.datetime "created_at"
39
42
  t.datetime "updated_at"
43
+ t.index ["acronym"], name: "index_addresses_countries_on_acronym"
44
+ t.index ["name"], name: "index_addresses_countries_on_name"
40
45
  end
41
46
 
42
47
  create_table "addresses_neighborhoods", force: :cascade do |t|
43
- t.integer "city_id"
44
- t.string "name"
48
+ t.integer "city_id"
49
+ t.string "name"
45
50
  t.datetime "created_at"
46
51
  t.datetime "updated_at"
47
52
  t.index ["city_id"], name: "index_addresses_neighborhoods_on_city_id"
53
+ t.index ["name", "city_id"], name: "index_addresses_neighborhoods_on_name_and_city_id"
54
+ t.index ["name"], name: "index_addresses_neighborhoods_on_name"
48
55
  end
49
56
 
50
57
  create_table "addresses_states", force: :cascade do |t|
51
- t.string "name"
52
- t.string "acronym"
53
- t.integer "country_id"
58
+ t.string "name"
59
+ t.string "acronym"
60
+ t.integer "country_id"
54
61
  t.datetime "created_at"
55
62
  t.datetime "updated_at"
56
63
  t.index ["country_id"], name: "index_addresses_states_on_country_id"
64
+ t.index ["name", "country_id"], name: "index_addresses_states_on_name_and_country_id"
65
+ t.index ["name"], name: "index_addresses_states_on_name"
57
66
  end
58
67
 
59
68
  create_table "addresses_zipcodes", force: :cascade do |t|
60
- t.string "street"
61
- t.integer "city_id"
62
- t.integer "neighborhood_id"
63
- t.string "number"
64
- t.datetime "created_at", null: false
65
- t.datetime "updated_at", null: false
69
+ t.string "street"
70
+ t.integer "city_id"
71
+ t.integer "neighborhood_id"
72
+ t.string "number"
73
+ t.datetime "created_at", null: false
74
+ t.datetime "updated_at", null: false
66
75
  t.index ["city_id"], name: "index_addresses_zipcodes_on_city_id"
67
76
  t.index ["neighborhood_id"], name: "index_addresses_zipcodes_on_neighborhood_id"
77
+ t.index ["number"], name: "index_addresses_zipcodes_on_number"
68
78
  end
69
79
 
70
80
  end