master
  1# This file is auto-generated from the current state of the database. Instead
  2# of editing this file, please use the migrations feature of Active Record to
  3# incrementally modify your database, and then regenerate this schema definition.
  4#
  5# Note that this schema.rb definition is the authoritative source for your
  6# database schema. If you need to create the application database on another
  7# system, you should be using db:schema:load, not running all the migrations
  8# from scratch. The latter is a flawed and unsustainable approach (the more migrations
  9# you'll amass, the slower it'll run and the greater likelihood for issues).
 10#
 11# It's strongly recommended that you check this file into your version control system.
 12
 13ActiveRecord::Schema.define(version: 20170831042718) do
 14
 15  # These are extensions that must be enabled in order to support this database
 16  enable_extension "plpgsql"
 17  enable_extension "uuid-ossp"
 18
 19  create_table "exercise_sets", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
 20    t.integer  "target_repetitions", null: false
 21    t.integer  "actual_repetitions"
 22    t.float    "target_weight",      null: false
 23    t.datetime "created_at",         null: false
 24    t.datetime "updated_at",         null: false
 25    t.uuid     "exercise_id",        null: false
 26    t.uuid     "workout_id"
 27    t.string   "type",               null: false
 28    t.integer  "target_duration"
 29    t.integer  "actual_duration"
 30    t.index ["exercise_id", "workout_id"], name: "index_exercise_sets_on_exercise_id_and_workout_id", using: :btree
 31    t.index ["exercise_id"], name: "index_exercise_sets_on_exercise_id", using: :btree
 32  end
 33
 34  create_table "exercises", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
 35    t.string   "name",       null: false
 36    t.datetime "created_at", null: false
 37    t.datetime "updated_at", null: false
 38  end
 39
 40  create_table "gyms", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
 41    t.string   "name",       null: false
 42    t.datetime "created_at", null: false
 43    t.datetime "updated_at", null: false
 44    t.string   "yelp_id"
 45    t.index ["yelp_id"], name: "index_gyms_on_yelp_id", unique: true, using: :btree
 46  end
 47
 48  create_table "locations", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
 49    t.uuid     "locatable_id"
 50    t.string   "locatable_type"
 51    t.decimal  "latitude",       precision: 10, scale: 6
 52    t.decimal  "longitude",      precision: 10, scale: 6
 53    t.string   "address"
 54    t.string   "city"
 55    t.string   "region"
 56    t.string   "country"
 57    t.string   "postal_code"
 58    t.datetime "created_at",                              null: false
 59    t.datetime "updated_at",                              null: false
 60    t.index ["locatable_id", "locatable_type"], name: "index_locations_on_locatable_id_and_locatable_type", using: :btree
 61  end
 62
 63  create_table "profiles", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
 64    t.uuid     "user_id",                          null: false
 65    t.integer  "gender",           default: 0
 66    t.integer  "social_tolerance"
 67    t.datetime "created_at",                       null: false
 68    t.datetime "updated_at",                       null: false
 69    t.string   "time_zone",        default: "UTC", null: false
 70    t.uuid     "gym_id"
 71    t.index ["gym_id"], name: "index_profiles_on_gym_id", using: :btree
 72    t.index ["user_id"], name: "index_profiles_on_user_id", unique: true, using: :btree
 73  end
 74
 75  create_table "programs", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
 76    t.string   "name",       null: false
 77    t.datetime "created_at", null: false
 78    t.datetime "updated_at", null: false
 79    t.string   "slug",       null: false
 80    t.index ["slug"], name: "index_programs_on_slug", unique: true, using: :btree
 81  end
 82
 83  create_table "received_emails", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
 84    t.uuid     "user_id"
 85    t.text     "to"
 86    t.text     "from"
 87    t.string   "subject"
 88    t.text     "body"
 89    t.datetime "created_at", null: false
 90    t.datetime "updated_at", null: false
 91    t.index ["user_id"], name: "index_received_emails_on_user_id", using: :btree
 92  end
 93
 94  create_table "recommendations", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
 95    t.uuid     "exercise_id", null: false
 96    t.uuid     "routine_id",  null: false
 97    t.integer  "sets",        null: false
 98    t.integer  "repetitions", null: false
 99    t.datetime "created_at",  null: false
100    t.datetime "updated_at",  null: false
101    t.integer  "duration"
102  end
103
104  create_table "routines", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
105    t.uuid     "program_id", null: false
106    t.string   "name",       null: false
107    t.datetime "created_at", null: false
108    t.datetime "updated_at", null: false
109    t.index ["program_id"], name: "index_routines_on_program_id", using: :btree
110  end
111
112  create_table "user_sessions", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
113    t.uuid     "user_id",     null: false
114    t.string   "ip"
115    t.text     "user_agent"
116    t.datetime "accessed_at"
117    t.datetime "revoked_at"
118    t.datetime "created_at",  null: false
119    t.datetime "updated_at",  null: false
120    t.index ["user_id"], name: "index_user_sessions_on_user_id", using: :btree
121  end
122
123  create_table "users", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
124    t.string   "username",        null: false
125    t.string   "email",           null: false
126    t.string   "password_digest"
127    t.datetime "created_at",      null: false
128    t.datetime "updated_at",      null: false
129    t.index ["email"], name: "index_users_on_email", unique: true, using: :btree
130    t.index ["username", "email"], name: "index_users_on_username_and_email", using: :btree
131    t.index ["username"], name: "index_users_on_username", unique: true, using: :btree
132  end
133
134  create_table "workouts", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
135    t.uuid     "user_id",     null: false
136    t.datetime "created_at",  null: false
137    t.datetime "updated_at",  null: false
138    t.uuid     "routine_id",  null: false
139    t.datetime "occurred_at", null: false
140    t.float    "body_weight"
141    t.index ["routine_id"], name: "index_workouts_on_routine_id", using: :btree
142    t.index ["user_id"], name: "index_workouts_on_user_id", using: :btree
143  end
144
145  add_foreign_key "profiles", "gyms"
146  add_foreign_key "received_emails", "users"
147  add_foreign_key "user_sessions", "users"
148end