diff --git a/app/models/exercise_type.rb b/app/models/exercise_type.rb new file mode 100644 index 0000000..26441fa --- /dev/null +++ b/app/models/exercise_type.rb @@ -0,0 +1,5 @@ +class ExerciseType < ApplicationRecord + validates :name, + :unit, + presence: true +end diff --git a/db/migrate/20231229112847_create_exercise_types.rb b/db/migrate/20231229112847_create_exercise_types.rb new file mode 100644 index 0000000..cf51922 --- /dev/null +++ b/db/migrate/20231229112847_create_exercise_types.rb @@ -0,0 +1,10 @@ +class CreateExerciseTypes < ActiveRecord::Migration[7.1] + def change + create_table :exercise_types do |t| + t.text :name, null: false + t.text :unit, null: false + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 02fed34..3afa1f7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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_112620) do +ActiveRecord::Schema[7.1].define(version: 2023_12_29_112847) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -63,6 +63,13 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_29_112620) do t.index ["user_id"], name: "index_blog_posts_on_user_id" end + create_table "exercise_types", force: :cascade do |t| + t.text "name", null: false + t.text "unit", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "foods", force: :cascade do |t| t.text "name", null: false t.datetime "created_at", null: false diff --git a/test/fixtures/exercise_types.yml b/test/fixtures/exercise_types.yml new file mode 100644 index 0000000..0f6cb6f --- /dev/null +++ b/test/fixtures/exercise_types.yml @@ -0,0 +1,7 @@ +running: + name: Running + unit: km + +cycling: + name: Running + unit: km