Drop states column
This commit is contained in:
@@ -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")
|
||||
|
||||
5
db/migrate/20251008151039_drop_park_states.rb
Normal file
5
db/migrate/20251008151039_drop_park_states.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class DropParkStates < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
remove_column :parks, :states, :text
|
||||
end
|
||||
end
|
||||
3
db/schema.rb
generated
3
db/schema.rb
generated
@@ -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
|
||||
|
||||
2
spec/fixtures/parks.yml
vendored
2
spec/fixtures/parks.yml
vendored
@@ -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: {}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user