diff --git a/app/services/seed/parks.rb b/app/services/seed/parks.rb index 6886464..d102180 100644 --- a/app/services/seed/parks.rb +++ b/app/services/seed/parks.rb @@ -12,7 +12,7 @@ class Seed::Parks parks = response_body['data'] .pluck('parkCode', 'name', 'states', 'activities', 'operatingHours') .map do |code, name, states, activities, operating_hours| - { code:, name:, states: , properties: { activities:, operating_hours: } } + { code:, name:, properties: { activities:, operating_hours: } } end Park.upsert_all(parks, unique_by: :code) Rails.logger.info("Upserted #{parks.count} national parks") diff --git a/db/migrate/20251008151039_drop_park_states.rb b/db/migrate/20251008151039_drop_park_states.rb new file mode 100644 index 0000000..bd1f4b0 --- /dev/null +++ b/db/migrate/20251008151039_drop_park_states.rb @@ -0,0 +1,5 @@ +class DropParkStates < ActiveRecord::Migration[8.0] + def change + remove_column :parks, :states, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 02b27b9..6af55f8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_10_08_150542) do +ActiveRecord::Schema[8.0].define(version: 2025_10_08_151039) do create_table "alerts", force: :cascade do |t| t.string "category", null: false t.text "description" @@ -28,7 +28,6 @@ ActiveRecord::Schema[8.0].define(version: 2025_10_08_150542) do create_table "parks", force: :cascade do |t| t.string "code", null: false t.string "name", null: false - t.text "states", null: false t.json "properties", default: {}, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false diff --git a/spec/fixtures/parks.yml b/spec/fixtures/parks.yml index 9d93279..e6eef30 100644 --- a/spec/fixtures/parks.yml +++ b/spec/fixtures/parks.yml @@ -3,11 +3,9 @@ one: code: crla name: Crater Lake National Park - states: OR properties: {} two: code: olym name: Olympic National Park - states: WA properties: {} diff --git a/spec/requests/api/v1/parks_spec.rb b/spec/requests/api/v1/parks_spec.rb index 5787004..9795a91 100644 --- a/spec/requests/api/v1/parks_spec.rb +++ b/spec/requests/api/v1/parks_spec.rb @@ -7,12 +7,12 @@ RSpec.describe "Api::V1::Parks", type: :request do expect(response).to have_http_status(:success) expect(response.parsed_body["parks"]).to include( hash_including( - code: "crla", name: "Crater Lake National Park", states: "OR" + code: "crla", name: "Crater Lake National Park" ) ) expect(response.parsed_body["parks"]).to include( hash_including( - code: "olym", name: "Olympic National Park", states: "WA" + code: "olym", name: "Olympic National Park" ) ) end @@ -49,7 +49,7 @@ RSpec.describe "Api::V1::Parks", type: :request do expect(response).to have_http_status(:success) expect(response.parsed_body).to match( hash_including( - code: "crla", name: "Crater Lake National Park", states: "OR" + code: "crla", name: "Crater Lake National Park" ) ) end