discourse/db/migrate/20140522003151_add_user_avatars.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00

34 lines
743 B
Ruby

# frozen_string_literal: true
class AddUserAvatars < ActiveRecord::Migration[4.2]
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
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