Skip to content
This repository

change the fitbit types in the db #54

Merged
merged 2 commits into from over 1 year ago

2 participants

Helge Rausch Philipp Bayer
Helge Rausch

No description provided.

Helge Rausch tsujigiri referenced this pull request
Closed

Database Types #52

Philipp Bayer philippbayer merged commit f9ee110 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Jan 24, 2013
Helge Rausch tsujigiri change the fitbit types in the db 815a20b
Helge Rausch tsujigiri removing a .new 36dd88b
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 33 additions and 37 deletions. Show diff stats Hide diff stats

  1. +18 22 db/migrate/20130124085042_change_fitbit_types.rb
  2. +15 15 db/schema.rb
40 db/migrate/20130124085042_change_fitbit_types.rb
... ... @@ -1,29 +1,25 @@
1 1 class ChangeFitbitTypes < ActiveRecord::Migration
2 2 def self.up
3   - change_column :fitbit_bodies, :weight, :float
4   - change_column :fitbit_bodies, :bmi, :float
5   - change_column :fitbit_activities, :steps, :int
6   - change_column :fitbit_activities, :floors, :int
7   - change_column :fitbit_sleeps, :minutes_awake, :int
8   - change_column :fitbit_sleeps, :minutes_asleep, :int
9   - change_column :fitbit_sleeps, :number_awakenings, :int
10   - change_column :fitbit_sleeps, :minutes_to_sleep, :int
11   - change_column :fitbit_sleeps, :date_logged, :date
12   - change_column :fitbit_bodies, :date_logged, :date
13   - change_column :fitbit_activities, :date_logged, :date
  3 + ActiveRecord::Base.connection.execute(<<-SQL)
  4 + ALTER TABLE fitbit_bodies ALTER weight TYPE float8 USING weight::float8
  5 + ,ALTER bmi TYPE float8 USING bmi::float8
  6 + ,ALTER date_logged TYPE date USING date_logged::date
  7 + SQL
  8 + ActiveRecord::Base.connection.execute(<<-SQL)
  9 + ALTER TABLE fitbit_activities ALTER steps TYPE integer USING steps::integer
  10 + ,ALTER floors TYPE integer USING floors::integer
  11 + ,ALTER date_logged TYPE date USING date_logged::date
  12 + SQL
  13 + ActiveRecord::Base.connection.execute(<<-SQL)
  14 + ALTER TABLE fitbit_sleeps ALTER minutes_awake TYPE integer USING minutes_awake::integer
  15 + ,ALTER minutes_asleep TYPE integer USING minutes_asleep::integer
  16 + ,ALTER number_awakenings TYPE integer USING number_awakenings::integer
  17 + ,ALTER minutes_to_sleep TYPE integer USING minutes_to_sleep::integer
  18 + ,ALTER date_logged TYPE date USING date_logged::date
  19 + SQL
14 20 end
15 21
16 22 def self.down
17   - change_column :fitbit_bodies, :weight, :string
18   - change_column :fitbit_bodies, :bmi, :string
19   - change_column :fitbit_activities, :steps, :string
20   - change_column :fitbit_activities, :floors, :string
21   - change_column :fitbit_sleeps, :minutes_awake, :string
22   - change_column :fitbit_sleeps, :minutes_asleep, :string
23   - change_column :fitbit_sleeps, :number_awakenings, :string
24   - change_column :fitbit_sleeps, :minutes_to_sleep, :string
25   - change_column :fitbit_sleeps, :date_logged, :string
26   - change_column :fitbit_bodies, :date_logged, :string
27   - change_column :fitbit_activities, :date_logged, :string
  23 + raise ActiveRecord::IrreversibleMigration
28 24 end
29 25 end
30 db/schema.rb
@@ -11,7 +11,7 @@
11 11 #
12 12 # It's strongly recommended to check this file into your version control system.
13 13
14   -ActiveRecord::Schema.define(:version => 20121213120010) do
  14 +ActiveRecord::Schema.define(:version => 20130124085042) do
15 15
16 16 create_table "achievements", :force => true do |t|
17 17 t.text "award"
@@ -29,18 +29,18 @@
29 29
30 30 create_table "fitbit_activities", :force => true do |t|
31 31 t.integer "fitbit_profile_id"
32   - t.string "steps"
33   - t.string "floors"
34   - t.string "date_logged"
  32 + t.integer "steps"
  33 + t.integer "floors"
  34 + t.date "date_logged"
35 35 t.datetime "created_at"
36 36 t.datetime "updated_at"
37 37 end
38 38
39 39 create_table "fitbit_bodies", :force => true do |t|
40 40 t.integer "fitbit_profile_id"
41   - t.string "date_logged"
42   - t.string "weight"
43   - t.string "bmi"
  41 + t.date "date_logged"
  42 + t.float "weight"
  43 + t.float "bmi"
44 44 t.datetime "created_at"
45 45 t.datetime "updated_at"
46 46 end
@@ -62,11 +62,11 @@
62 62
63 63 create_table "fitbit_sleeps", :force => true do |t|
64 64 t.integer "fitbit_profile_id"
65   - t.string "minutes_asleep"
66   - t.string "minutes_awake"
67   - t.string "number_awakenings"
68   - t.string "minutes_to_sleep"
69   - t.string "date_logged"
  65 + t.integer "minutes_asleep"
  66 + t.integer "minutes_awake"
  67 + t.integer "number_awakenings"
  68 + t.integer "minutes_to_sleep"
  69 + t.date "date_logged"
70 70 t.datetime "created_at"
71 71 t.datetime "updated_at"
72 72 end
@@ -242,9 +242,9 @@
242 242 t.string "allele_frequency"
243 243 t.integer "ranking"
244 244 t.integer "number_of_users", :default => 0
245   - t.datetime "mendeley_updated", :default => '2012-11-29 19:09:23'
246   - t.datetime "plos_updated", :default => '2012-11-29 19:09:23'
247   - t.datetime "snpedia_updated", :default => '2012-11-29 19:09:23'
  245 + t.datetime "mendeley_updated", :default => '2012-11-08 23:24:59'
  246 + t.datetime "plos_updated", :default => '2012-11-08 23:24:59'
  247 + t.datetime "snpedia_updated", :default => '2012-11-08 23:24:59'
248 248 t.datetime "created_at"
249 249 t.datetime "updated_at"
250 250 end

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.