create event model
This commit is contained in:
parent
77fb22bdb4
commit
bb3e42efc3
3 changed files with 23 additions and 2 deletions
9
db/migrate/20241101211840_create_events.rb
Normal file
9
db/migrate/20241101211840_create_events.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
class CreateEvents < ActiveRecord::Migration[7.2]
|
||||||
|
def change
|
||||||
|
create_table :events do |t|
|
||||||
|
t.string :title
|
||||||
|
t.text :description
|
||||||
|
t.datetime :taken_place_on, precision: nil, null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -10,10 +10,15 @@
|
||||||
#
|
#
|
||||||
# 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[7.1].define(version: 2024_02_11_182231) do
|
ActiveRecord::Schema[7.2].define(version: 2024_11_01_211840) do
|
||||||
|
create_table "events", force: :cascade do |t|
|
||||||
|
t.string "title"
|
||||||
|
t.text "description"
|
||||||
|
t.datetime "taken_place_on", precision: nil, null: false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "moods", force: :cascade do |t|
|
create_table "moods", force: :cascade do |t|
|
||||||
t.string "mode", null: false
|
t.string "mode", null: false
|
||||||
t.datetime "recorded_at", precision: nil, null: false
|
t.datetime "recorded_at", precision: nil, null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
7
event.rb
Normal file
7
event.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
class Event < ActiveRecord::Base
|
||||||
|
default_scope { order(:taken_place_on) }
|
||||||
|
validates_presence_of :title
|
||||||
|
validates_presence_of :taken_place_on
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue