Add diary entries
This commit is contained in:
parent
16adb83240
commit
20ff7d1764
|
@ -0,0 +1,11 @@
|
||||||
|
class DiaryEntry < ApplicationRecord
|
||||||
|
belongs_to :user
|
||||||
|
|
||||||
|
validates :date,
|
||||||
|
:pain_level,
|
||||||
|
:energy_level,
|
||||||
|
:mental_alertness_level,
|
||||||
|
:work_stress_level,
|
||||||
|
:life_stress_level,
|
||||||
|
presence: true
|
||||||
|
end
|
|
@ -0,0 +1,17 @@
|
||||||
|
class CreateDiaryEntries < ActiveRecord::Migration[7.1]
|
||||||
|
def change
|
||||||
|
create_table :diary_entries do |t|
|
||||||
|
t.text :notes, null: false, default: ''
|
||||||
|
t.date :date, null: false
|
||||||
|
t.references :user, null: false, foreign_key: true
|
||||||
|
t.integer :pain_level, null: false
|
||||||
|
t.integer :energy_level, null: false
|
||||||
|
t.integer :mental_alertness_level, null: false
|
||||||
|
t.integer :work_stress_level, null: false
|
||||||
|
t.integer :life_stress_level, null: false
|
||||||
|
t.integer :sleep_quality_level, null: false
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -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[7.1].define(version: 2023_12_29_114145) do
|
ActiveRecord::Schema[7.1].define(version: 2023_12_29_114804) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
|
@ -63,6 +63,21 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_29_114145) do
|
||||||
t.index ["user_id"], name: "index_blog_posts_on_user_id"
|
t.index ["user_id"], name: "index_blog_posts_on_user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "diary_entries", force: :cascade do |t|
|
||||||
|
t.text "notes", default: "", null: false
|
||||||
|
t.date "date", null: false
|
||||||
|
t.bigint "user_id", null: false
|
||||||
|
t.integer "pain_level", null: false
|
||||||
|
t.integer "energy_level", null: false
|
||||||
|
t.integer "mental_alertness_level", null: false
|
||||||
|
t.integer "work_stress_level", null: false
|
||||||
|
t.integer "life_stress_level", null: false
|
||||||
|
t.integer "sleep_quality_level", null: false
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["user_id"], name: "index_diary_entries_on_user_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "exercise_types", force: :cascade do |t|
|
create_table "exercise_types", force: :cascade do |t|
|
||||||
t.text "name", null: false
|
t.text "name", null: false
|
||||||
t.text "unit", null: false
|
t.text "unit", null: false
|
||||||
|
@ -128,6 +143,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_29_114145) do
|
||||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||||
add_foreign_key "blog_posts", "users"
|
add_foreign_key "blog_posts", "users"
|
||||||
|
add_foreign_key "diary_entries", "users"
|
||||||
add_foreign_key "exercises", "exercise_types"
|
add_foreign_key "exercises", "exercise_types"
|
||||||
add_foreign_key "microposts", "users"
|
add_foreign_key "microposts", "users"
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
one:
|
||||||
|
user: tsvallender
|
||||||
|
date: 2023-12-29
|
||||||
|
notes: Oh, what a day
|
||||||
|
exercise: one
|
||||||
|
pain_level: 10
|
||||||
|
energy_level: 10
|
||||||
|
mental_alertness_level: 10
|
||||||
|
work_stress_level: 10
|
||||||
|
life_stress_level: 10
|
||||||
|
|
||||||
|
two:
|
||||||
|
user: tsvallender
|
||||||
|
date: 2023-12-28
|
||||||
|
notes: Wow
|
||||||
|
exercise: two
|
||||||
|
pain_level: 1
|
||||||
|
energy_level: 1
|
||||||
|
mental_alertness_level: 1
|
||||||
|
work_stress_level: 1
|
||||||
|
life_stress_level: 1
|
|
@ -0,0 +1,4 @@
|
||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class DiaryEntryTest < ActiveSupport::TestCase
|
||||||
|
end
|
Loading…
Reference in New Issue