Chatwoot/db/migrate/20210923190418_add_online_status_to_account_users.rb
Sojan Jose c54aae21ff
chore: Move agent availability to Account level (#3074)
- Move agent availability to the account level
2021-10-07 13:21:46 +05:30

21 lines
553 B
Ruby

class AddOnlineStatusToAccountUsers < ActiveRecord::Migration[6.1]
def change
change_table :account_users, bulk: true do |t|
t.integer :availability, default: 0, null: false
t.boolean :auto_offline, default: true, null: false
end
update_existing_user_availability
end
private
def update_existing_user_availability
User.find_in_batches do |user_batch|
user_batch.each do |user|
availability = user.availability
user.account_users.update(availability: availability)
end
end
end
end