Add alert model
This commit is contained in:
2
app/models/alert.rb
Normal file
2
app/models/alert.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class Alert < ApplicationRecord
|
||||
end
|
||||
17
db/migrate/20251008063847_create_alerts.rb
Normal file
17
db/migrate/20251008063847_create_alerts.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class CreateAlerts < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :alerts do |t|
|
||||
t.string :category, null: false
|
||||
t.text :description
|
||||
t.string :park_code, null: false
|
||||
t.string :title, null: false
|
||||
t.string :url
|
||||
t.timestamp :indexed_date
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :alerts, :park_code
|
||||
add_foreign_key :alerts, :parks, column: :park_code, primary_key: :code
|
||||
end
|
||||
end
|
||||
16
db/schema.rb
generated
16
db/schema.rb
generated
@@ -10,7 +10,19 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_10_08_044109) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_10_08_063847) do
|
||||
create_table "alerts", force: :cascade do |t|
|
||||
t.string "category", null: false
|
||||
t.text "description"
|
||||
t.string "park_code", null: false
|
||||
t.string "title", null: false
|
||||
t.string "url"
|
||||
t.datetime "indexed_date"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["park_code"], name: "index_alerts_on_park_code"
|
||||
end
|
||||
|
||||
create_table "parks", force: :cascade do |t|
|
||||
t.string "code", null: false
|
||||
t.string "name", null: false
|
||||
@@ -20,4 +32,6 @@ ActiveRecord::Schema[8.0].define(version: 2025_10_08_044109) do
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["code"], name: "index_parks_on_code", unique: true
|
||||
end
|
||||
|
||||
add_foreign_key "alerts", "parks", column: "park_code", primary_key: "code"
|
||||
end
|
||||
|
||||
5
spec/models/alert_spec.rb
Normal file
5
spec/models/alert_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Alert, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
Reference in New Issue
Block a user