discourse/db/migrate/20140522003151_add_user_ava...

32 lines
707 B
Ruby
Raw Normal View History

class AddUserAvatars < ActiveRecord::Migration
def up
create_table :user_avatars do |t|
t.integer :user_id, null: false
t.integer :system_upload_id
t.integer :custom_upload_id
t.integer :gravatar_upload_id
t.datetime :last_gravatar_download_attempt
2017-08-07 11:48:36 -04:00
t.timestamps null: false
end
add_index :user_avatars, [:user_id]
execute <<SQL
INSERT INTO user_avatars(user_id, custom_upload_id)
SELECT id, uploaded_avatar_id
FROM users
SQL
execute <<SQL
UPDATE users SET uploaded_avatar_id = NULL
WHERE NOT use_uploaded_avatar
SQL
# NOTE we should nuke use_uploaded_avatar later on
end
def down
drop_table :user_avatars
end
end