run the migration script on assignment v2 toggle
This commit is contained in:
@@ -43,7 +43,7 @@ const transformedValue = computed({
|
||||
},
|
||||
set(newValue) {
|
||||
if (newValue == null || newValue === '') {
|
||||
duration.value = props.min || null;
|
||||
duration.value = null;
|
||||
return;
|
||||
}
|
||||
let minuteValue = convertToMinutes(newValue);
|
||||
|
||||
+6
-15
@@ -1,20 +1,9 @@
|
||||
class MigrateMaxAssignmentLimitToPolicies < ActiveRecord::Migration[7.1]
|
||||
# Ruby's max for a 32-bit signed integer, matching PostgreSQL's integer column limit
|
||||
class Migration::AccountAssignmentPolicyJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
INT_MAX = (2**31) - 1
|
||||
|
||||
def up
|
||||
Account.find_each do |account|
|
||||
migrate_account(account)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
AgentCapacityPolicy.where(name: 'Auto Assignment Capacity').destroy_all
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def migrate_account(account)
|
||||
def perform(account)
|
||||
inboxes_with_limit = account.inboxes
|
||||
.where("auto_assignment_config->>'max_assignment_limit' ~ '^[1-9]'")
|
||||
|
||||
@@ -30,6 +19,8 @@ class MigrateMaxAssignmentLimitToPolicies < ActiveRecord::Migration[7.1]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_inbox_limits(policy, inboxes)
|
||||
inboxes.each do |inbox|
|
||||
next if InboxCapacityLimit.exists?(agent_capacity_policy_id: policy.id, inbox_id: inbox.id)
|
||||
@@ -44,6 +44,7 @@ module Enterprise::Account
|
||||
if feature_enabled?('assignment_v2')
|
||||
# Enable advanced_assignment for Business/Enterprise plans
|
||||
send('feature_advanced_assignment=', true) if business_or_enterprise_plan?
|
||||
Migration::AccountAssignmentPolicyJob.perform_later(self)
|
||||
else
|
||||
# Disable advanced_assignment when assignment_v2 is disabled
|
||||
send('feature_advanced_assignment=', false)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# Manually run the max_assignment_limit to agent capacity policy migration.
|
||||
# This is idempotent and safe to run multiple times.
|
||||
#
|
||||
# Usage:
|
||||
# bundle exec rake assignment:migrate_max_limit
|
||||
namespace :assignment do
|
||||
desc 'Migrate max_assignment_limit from inbox config to agent capacity policies'
|
||||
task migrate_max_limit: :environment do
|
||||
require Rails.root.join('db/migrate/20260316000001_migrate_max_assignment_limit_to_policies')
|
||||
MigrateMaxAssignmentLimitToPolicies.new.up
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user