Skip to content
Permalink
Browse files
Create Total model.
  • Loading branch information
Steve Polito committed Aug 21, 2020
1 parent df0a775 commit bdd26a10b8381dd4ecf1a511a76ca0ed33b0f783
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
@@ -0,0 +1,3 @@
class Total < ApplicationRecord
belongs_to :user
end
@@ -0,0 +1,12 @@
class CreateTotals < ActiveRecord::Migration[6.0]
def change
create_table :totals do |t|
t.references :user, null: false, foreign_key: true
t.date :date, null: false
t.integer :duration, default: 0
t.decimal :distance, default: 0

t.timestamps
end
end
end
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2020_08_17_111403) do
ActiveRecord::Schema.define(version: 2020_08_21_110618) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -63,6 +63,16 @@
t.index ["user_id"], name: "index_activities_on_user_id"
end

create_table "totals", force: :cascade do |t|
t.bigint "user_id", null: false
t.date "date", null: false
t.integer "duration", default: 0
t.decimal "distance", default: "0.0"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["user_id"], name: "index_totals_on_user_id"
end

create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
@@ -83,4 +93,5 @@

add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "activities", "users"
add_foreign_key "totals", "users"
end
@@ -0,0 +1,13 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
user: one
date: 2020-08-21
duration: 1
distance: 9.99

two:
user: two
date: 2020-08-21
duration: 1
distance: 9.99
@@ -0,0 +1,7 @@
require 'test_helper'

class TotalTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit bdd26a1

Please sign in to comment.