Permalink
Browse files

change the fitbit types in the db

  • Loading branch information...
1 parent 20eef53 commit 815a20bfe7f68bd10c5cd74bedb4a8174a9d3928 @tsujigiri committed Jan 24, 2013
Showing with 33 additions and 37 deletions.
  1. +18 −22 db/migrate/20130124085042_change_fitbit_types.rb
  2. +15 −15 db/schema.rb
@@ -1,29 +1,25 @@
class ChangeFitbitTypes < ActiveRecord::Migration
def self.up
- change_column :fitbit_bodies, :weight, :float
- change_column :fitbit_bodies, :bmi, :float
- change_column :fitbit_activities, :steps, :int
- change_column :fitbit_activities, :floors, :int
- change_column :fitbit_sleeps, :minutes_awake, :int
- change_column :fitbit_sleeps, :minutes_asleep, :int
- change_column :fitbit_sleeps, :number_awakenings, :int
- change_column :fitbit_sleeps, :minutes_to_sleep, :int
- change_column :fitbit_sleeps, :date_logged, :date
- change_column :fitbit_bodies, :date_logged, :date
- change_column :fitbit_activities, :date_logged, :date
+ ActiveRecord::Base.connection.execute(<<-SQL)
+ ALTER TABLE fitbit_bodies ALTER weight TYPE float8 USING weight::float8
+ ,ALTER bmi TYPE float8 USING bmi::float8
+ ,ALTER date_logged TYPE date USING date_logged::date
+ SQL
+ ActiveRecord::Base.connection.execute(<<-SQL)
+ ALTER TABLE fitbit_activities ALTER steps TYPE integer USING steps::integer
+ ,ALTER floors TYPE integer USING floors::integer
+ ,ALTER date_logged TYPE date USING date_logged::date
+ SQL
+ ActiveRecord::Base.connection.execute(<<-SQL)
+ ALTER TABLE fitbit_sleeps ALTER minutes_awake TYPE integer USING minutes_awake::integer
+ ,ALTER minutes_asleep TYPE integer USING minutes_asleep::integer
+ ,ALTER number_awakenings TYPE integer USING number_awakenings::integer
+ ,ALTER minutes_to_sleep TYPE integer USING minutes_to_sleep::integer
+ ,ALTER date_logged TYPE date USING date_logged::date
+ SQL
end
def self.down
- change_column :fitbit_bodies, :weight, :string
- change_column :fitbit_bodies, :bmi, :string
- change_column :fitbit_activities, :steps, :string
- change_column :fitbit_activities, :floors, :string
- change_column :fitbit_sleeps, :minutes_awake, :string
- change_column :fitbit_sleeps, :minutes_asleep, :string
- change_column :fitbit_sleeps, :number_awakenings, :string
- change_column :fitbit_sleeps, :minutes_to_sleep, :string
- change_column :fitbit_sleeps, :date_logged, :string
- change_column :fitbit_bodies, :date_logged, :string
- change_column :fitbit_activities, :date_logged, :string
+ raise ActiveRecord::IrreversibleMigration.new
end
end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20121213120010) do
+ActiveRecord::Schema.define(:version => 20130124085042) do
create_table "achievements", :force => true do |t|
t.text "award"
@@ -29,18 +29,18 @@
create_table "fitbit_activities", :force => true do |t|
t.integer "fitbit_profile_id"
- t.string "steps"
- t.string "floors"
- t.string "date_logged"
+ t.integer "steps"
+ t.integer "floors"
+ t.date "date_logged"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "fitbit_bodies", :force => true do |t|
t.integer "fitbit_profile_id"
- t.string "date_logged"
- t.string "weight"
- t.string "bmi"
+ t.date "date_logged"
+ t.float "weight"
+ t.float "bmi"
t.datetime "created_at"
t.datetime "updated_at"
end
@@ -62,11 +62,11 @@
create_table "fitbit_sleeps", :force => true do |t|
t.integer "fitbit_profile_id"
- t.string "minutes_asleep"
- t.string "minutes_awake"
- t.string "number_awakenings"
- t.string "minutes_to_sleep"
- t.string "date_logged"
+ t.integer "minutes_asleep"
+ t.integer "minutes_awake"
+ t.integer "number_awakenings"
+ t.integer "minutes_to_sleep"
+ t.date "date_logged"
t.datetime "created_at"
t.datetime "updated_at"
end
@@ -242,9 +242,9 @@
t.string "allele_frequency"
t.integer "ranking"
t.integer "number_of_users", :default => 0
- t.datetime "mendeley_updated", :default => '2012-11-29 19:09:23'
- t.datetime "plos_updated", :default => '2012-11-29 19:09:23'
- t.datetime "snpedia_updated", :default => '2012-11-29 19:09:23'
+ t.datetime "mendeley_updated", :default => '2012-11-08 23:24:59'
+ t.datetime "plos_updated", :default => '2012-11-08 23:24:59'
+ t.datetime "snpedia_updated", :default => '2012-11-08 23:24:59'
t.datetime "created_at"
t.datetime "updated_at"
end

0 comments on commit 815a20b

Please sign in to comment.