Improve exercise schema

This commit is contained in:
Trevor Vallender 2023-12-29 14:42:32 +00:00
parent 7ff8075d64
commit 4170bb9b3e
4 changed files with 10 additions and 9 deletions

View File

@ -1,5 +0,0 @@
class DropFoods < ActiveRecord::Migration[7.1]
def change
drop_table :foods
end
end

View File

@ -0,0 +1,6 @@
class RenameAtOnExercises < ActiveRecord::Migration[7.1]
def change
remove_column :exercises, :at
add_column :exercises, :occurred_at, :datetime
end
end

4
db/schema.rb generated
View File

@ -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_143648) do ActiveRecord::Schema[7.1].define(version: 2023_12_29_143820) 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"
@ -87,11 +87,11 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_29_143648) do
create_table "exercises", force: :cascade do |t| create_table "exercises", force: :cascade do |t|
t.bigint "exercise_type_id", null: false t.bigint "exercise_type_id", null: false
t.time "at"
t.float "amount", null: false t.float "amount", null: false
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.bigint "diary_entry_id", null: false t.bigint "diary_entry_id", null: false
t.datetime "occurred_at"
t.index ["diary_entry_id"], name: "index_exercises_on_diary_entry_id" t.index ["diary_entry_id"], name: "index_exercises_on_diary_entry_id"
t.index ["exercise_type_id"], name: "index_exercises_on_exercise_type_id" t.index ["exercise_type_id"], name: "index_exercises_on_exercise_type_id"
end end

View File

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