Add parks_by_state model

This commit is contained in:
2025-10-08 08:08:00 -07:00
parent 4806a59d96
commit 513f1334fb
4 changed files with 31 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
class ParksByState < ApplicationRecord
end

View 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
View File

@@ -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

View File

@@ -0,0 +1,4 @@
require 'rails_helper'
RSpec.describe ParksByState, type: :model do
end