Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

228 remove location columns on organizations table and add zipcode to locations table #230

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# latitude :float
# longitude :float
# province_state :string
# zipcode :string
# created_at :datetime not null
# updated_at :datetime not null
#
Expand Down
3 changes: 0 additions & 3 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
# Table name: organizations
#
# id :bigint not null, primary key
# city :string
# country :string
# name :string
# slug :string
# zipcode :string
# created_at :datetime not null
# updated_at :datetime not null
#
Expand Down
2 changes: 1 addition & 1 deletion app/views/organizations/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="row d-flex align-items-center">
<div class="col-xxl-5 col-xl-6 col-lg-6 col-12">
<div>
<h1 class="display-2 fw-bold mb-3">Rescue pets in <%= Current.organization.city %> at <u class="text-warning"><span class="text-primary"> <%= Current.organization.name %></span></u></h1>
<h1 class="display-2 fw-bold mb-3">Rescue pets near you at <u class="text-warning"><span class="text-primary"> <%= Current.organization.name %></span></u></h1>
<p class="lead mb-4">Rescue a really cute pet and be a hero</p>
<ul class="list-unstyled mb-5">
<li class="mb-2">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class RemoveLocationFieldsFromOrganizations < ActiveRecord::Migration[7.0]
def up
safety_assured do
remove_column :organizations, :city, :string
remove_column :organizations, :country, :string
remove_column :organizations, :zipcode, :string
end
end

def down
add_column :organizations, :city, :string
add_column :organizations, :country, :string
add_column :organizations, :zipcode, :string
end
end
9 changes: 9 additions & 0 deletions db/migrate/20231003095748_add_zipcode_to_locations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddZipcodeToLocations < ActiveRecord::Migration[7.0]
def up
add_column :locations, :zipcode, :string
end

def down
safety_assured { remove_column :locations, :zipcode, :string }
end
end
6 changes: 2 additions & 4 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions db/seeds/01_alta.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
organization = Organization.create!(
name: "Alta Pet Rescue",
city: "Alta",
country: "Mexico",
zipcode: "12345",
slug: "alta"
)

Expand Down Expand Up @@ -75,7 +72,8 @@
@location_one = Location.create!(
country: "Canada",
province_state: "Alberta",
city_town: "Canmore"
city_town: "Canmore",
zipcode: "12345"
)

@adopter_profile_one = AdopterProfile.create!(
Expand Down Expand Up @@ -118,7 +116,8 @@
@location_two = Location.create!(
country: "USA",
province_state: "Nevada",
city_town: "Reno"
city_town: "Reno",
zipcode: "12345"
)

@adopter_profile_two = AdopterProfile.create!(
Expand Down Expand Up @@ -164,7 +163,8 @@
@location_three = Location.create!(
country: "Nonsense",
province_state: "Nonsense",
city_town: "Nonsense"
city_town: "Nonsense",
zipcode: "12345"
)

@adopter_profile_three = AdopterProfile.create!(
Expand Down
12 changes: 6 additions & 6 deletions db/seeds/02_baja.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
organization = Organization.create!(
name: "Baja",
city: "Baja",
country: "Mexico",
zipcode: "12345",
slug: "baja"
)
ActsAsTenant.with_tenant(organization) do
Expand Down Expand Up @@ -74,7 +71,8 @@
@location_one = Location.create!(
country: "Canada",
province_state: "Alberta",
city_town: "Canmore"
city_town: "Canmore",
zipcode: "12345"
)

@adopter_profile_one = AdopterProfile.create!(
Expand Down Expand Up @@ -117,7 +115,8 @@
@location_two = Location.create!(
country: "USA",
province_state: "Nevada",
city_town: "Reno"
city_town: "Reno",
zipcode: "12345"
)

@adopter_profile_two = AdopterProfile.create!(
Expand Down Expand Up @@ -163,7 +162,8 @@
@location_three = Location.create!(
country: "Nonsense",
province_state: "Nonsense",
city_town: "Nonsense"
city_town: "Nonsense",
zipcode: "12345"
)

@adopter_profile_three = AdopterProfile.create!(
Expand Down
1 change: 1 addition & 0 deletions test/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
city_town { Faker::Address.city }
sequence(:country) { |n| "Country#{n}" }
province_state { Faker::Address.state }
zipcode { Faker::Address.zip_code }

trait :with_adopter_profile do
after :create do |location|
Expand Down