move bio to UserProfile from User

This commit is contained in:
Andrew Bezzub
2014-06-10 01:19:08 -04:00
committed by Robin Ward
parent 10f0ddbbdd
commit 9ffd173873
12 changed files with 211 additions and 105 deletions

View File

@@ -13,8 +13,6 @@ User.seed do |u|
u.username_lower = "system"
u.email = "no_email"
u.password = SecureRandom.hex
# TODO localize this, its going to require a series of hacks
u.bio_raw = "Not a real person. A global user for system notifications and other system tasks."
u.active = true
u.admin = true
u.moderator = true

View File

@@ -0,0 +1,25 @@
class MoveBioToUserProfiles < ActiveRecord::Migration
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