This commit is contained in:
Albert Yi
2018-04-25 14:31:11 -07:00
parent af3404b087
commit b0a3f574ed
5 changed files with 108 additions and 33 deletions

View File

@@ -0,0 +1,8 @@
class AddDmailCountToUsers < ActiveRecord::Migration[5.1]
def change
ApplicationRecord.without_timeout do
add_column :users, :unread_dmail_count, :integer, default: 0, null: false
execute "update users set unread_dmail_count = (select count(*) from dmails where dmails.owner_id = users.id and dmails.is_read = false)"
end
end
end