Add exercises

This commit is contained in:
Trevor Vallender 2023-12-29 11:44:35 +00:00
parent 500f5bd02e
commit 16adb83240
4 changed files with 34 additions and 1 deletions

3
app/models/exercise.rb Normal file
View File

@ -0,0 +1,3 @@
class Exercise < ApplicationRecord
belongs_to :type
end

View File

@ -0,0 +1,11 @@
class CreateExercises < ActiveRecord::Migration[7.1]
def change
create_table :exercises do |t|
t.references :exercise_type, null: false, foreign_key: true
t.time :at
t.float :amount, null: false
t.timestamps
end
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.
ActiveRecord::Schema[7.1].define(version: 2023_12_29_112847) do
ActiveRecord::Schema[7.1].define(version: 2023_12_29_114145) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -70,6 +70,15 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_29_112847) do
t.datetime "updated_at", null: false
end
create_table "exercises", force: :cascade do |t|
t.bigint "exercise_type_id", null: false
t.time "at"
t.float "amount", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["exercise_type_id"], name: "index_exercises_on_exercise_type_id"
end
create_table "foods", force: :cascade do |t|
t.text "name", null: false
t.datetime "created_at", null: false
@ -119,5 +128,6 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_29_112847) do
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 "blog_posts", "users"
add_foreign_key "exercises", "exercise_types"
add_foreign_key "microposts", "users"
end

9
test/fixtures/exercises.yml vendored Normal file
View File

@ -0,0 +1,9 @@
one:
exercise_type: running
at: 2023-12-29 11:41:45
amount: 5
two:
exercise_type: cycling
at: 2023-12-29 11:41:45
amount: 10.5