Add parks_by_state model
This commit is contained in:
2
app/models/parks_by_state.rb
Normal file
2
app/models/parks_by_state.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
class ParksByState < ApplicationRecord
|
||||||
|
end
|
||||||
14
db/migrate/20251008150542_create_parks_by_states.rb
Normal file
14
db/migrate/20251008150542_create_parks_by_states.rb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
class CreateParksByStates < ActiveRecord::Migration[8.0]
|
||||||
|
def change
|
||||||
|
create_table :parks_by_states do |t|
|
||||||
|
t.string :park_code, null: false
|
||||||
|
t.string :state, null: false
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :parks_by_states, [:state, :park_code], unique: true
|
||||||
|
add_index :parks_by_states, :park_code
|
||||||
|
add_foreign_key :parks_by_states, :parks, column: :park_code, primary_key: :code
|
||||||
|
end
|
||||||
|
end
|
||||||
12
db/schema.rb
generated
12
db/schema.rb
generated
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.0].define(version: 2025_10_08_063847) do
|
ActiveRecord::Schema[8.0].define(version: 2025_10_08_150542) do
|
||||||
create_table "alerts", force: :cascade do |t|
|
create_table "alerts", force: :cascade do |t|
|
||||||
t.string "category", null: false
|
t.string "category", null: false
|
||||||
t.text "description"
|
t.text "description"
|
||||||
@@ -35,5 +35,15 @@ ActiveRecord::Schema[8.0].define(version: 2025_10_08_063847) do
|
|||||||
t.index ["code"], name: "index_parks_on_code", unique: true
|
t.index ["code"], name: "index_parks_on_code", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "parks_by_states", force: :cascade do |t|
|
||||||
|
t.string "park_code", null: false
|
||||||
|
t.string "state", null: false
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["park_code"], name: "index_parks_by_states_on_park_code"
|
||||||
|
t.index ["state", "park_code"], name: "index_parks_by_states_on_state_and_park_code", unique: true
|
||||||
|
end
|
||||||
|
|
||||||
add_foreign_key "alerts", "parks", column: "park_code", primary_key: "code"
|
add_foreign_key "alerts", "parks", column: "park_code", primary_key: "code"
|
||||||
|
add_foreign_key "parks_by_states", "parks", column: "park_code", primary_key: "code"
|
||||||
end
|
end
|
||||||
|
|||||||
4
spec/models/parks_by_state_spec.rb
Normal file
4
spec/models/parks_by_state_spec.rb
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe ParksByState, type: :model do
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user