Compare commits
3 Commits
e1e3ef94be
...
16adb83240
Author | SHA1 | Date |
---|---|---|
Trevor Vallender | 16adb83240 | |
Trevor Vallender | 500f5bd02e | |
Trevor Vallender | 7615febc5d |
|
@ -0,0 +1,3 @@
|
||||||
|
class Exercise < ApplicationRecord
|
||||||
|
belongs_to :type
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ExerciseType < ApplicationRecord
|
||||||
|
validates :name,
|
||||||
|
:unit,
|
||||||
|
presence: true
|
||||||
|
end
|
|
@ -0,0 +1,3 @@
|
||||||
|
class Food < ApplicationRecord
|
||||||
|
validates :name, presence: true
|
||||||
|
end
|
|
@ -3,12 +3,14 @@ default: &default
|
||||||
encoding: unicode
|
encoding: unicode
|
||||||
# For details on connection pooling, see Rails configuration guide
|
# For details on connection pooling, see Rails configuration guide
|
||||||
# https://guides.rubyonrails.org/configuring.html#database-pooling
|
# https://guides.rubyonrails.org/configuring.html#database-pooling
|
||||||
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
host: localhost
|
||||||
username: soc
|
username: postgres
|
||||||
|
password: postgres
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: soc_development
|
database: soc_development
|
||||||
|
username: postgres
|
||||||
password: postgres
|
password: postgres
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
@ -20,3 +22,4 @@ production:
|
||||||
database: soc_production
|
database: soc_production
|
||||||
password: <%= ENV["POSTGRES_PASSWORD"] %>
|
password: <%= ENV["POSTGRES_PASSWORD"] %>
|
||||||
host: <%= ENV.fetch("DB_HOST") { 'localhost' } %>
|
host: <%= ENV.fetch("DB_HOST") { 'localhost' } %>
|
||||||
|
username: soc
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
class CreateFoods < ActiveRecord::Migration[7.1]
|
||||||
|
def change
|
||||||
|
create_table :foods do |t|
|
||||||
|
t.text :name, null: false
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -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
|
|
@ -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
|
|
@ -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_10_19_192600) 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
|
@ -63,6 +63,28 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_19_192600) 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 "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 "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
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "microposts", force: :cascade do |t|
|
create_table "microposts", force: :cascade do |t|
|
||||||
t.bigint "user_id", null: false
|
t.bigint "user_id", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
|
@ -106,5 +128,6 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_19_192600) 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 "exercises", "exercise_types"
|
||||||
add_foreign_key "microposts", "users"
|
add_foreign_key "microposts", "users"
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
running:
|
||||||
|
name: Running
|
||||||
|
unit: km
|
||||||
|
|
||||||
|
cycling:
|
||||||
|
name: Running
|
||||||
|
unit: km
|
|
@ -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
|
|
@ -0,0 +1,5 @@
|
||||||
|
one:
|
||||||
|
name: Pizza
|
||||||
|
|
||||||
|
two:
|
||||||
|
name: Banana
|
Loading…
Reference in New Issue