2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-30 23:06:56 -05:00
|
|
|
class MoveBioToUserProfiles < ActiveRecord::Migration[4.2]
|
2014-06-10 00:19:08 -05:00
|
|
|
def up
|
|
|
|
add_column :user_profiles, :bio_raw, :text
|
|
|
|
add_column :user_profiles, :bio_cooked, :text
|
|
|
|
|
|
|
|
execute "UPDATE user_profiles SET bio_raw = subquery.bio_raw, bio_cooked = subquery.bio_cooked FROM (
|
|
|
|
SELECT bio_raw, bio_cooked, id FROM users
|
|
|
|
) as subquery WHERE user_profiles.user_id = subquery.id"
|
|
|
|
|
|
|
|
remove_column :users, :bio_raw
|
|
|
|
remove_column :users, :bio_cooked
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
add_column :users, :bio_raw, :text
|
|
|
|
add_column :users, :bio_cooked, :text
|
|
|
|
|
|
|
|
execute "UPDATE users SET bio_raw = subquery.bio_raw, bio_cooked = subquery.bio_cooked FROM (
|
|
|
|
SELECT bio_raw, bio_cooked, user_id FROM user_profiles
|
|
|
|
) as subquery WHERE users.id = subquery.user_id"
|
|
|
|
|
|
|
|
remove_column :user_profiles, :bio_raw
|
|
|
|
remove_column :user_profiles, :bio_cooked
|
|
|
|
end
|
|
|
|
end
|