diff --git a/app/models/ckb_sync/new_node_data_processor.rb b/app/models/ckb_sync/new_node_data_processor.rb index ae2134539..d27834518 100644 --- a/app/models/ckb_sync/new_node_data_processor.rb +++ b/app/models/ckb_sync/new_node_data_processor.rb @@ -355,7 +355,17 @@ def update_addresses_dao_info(addrs_deposit_info) is_depositor: address_info[:is_depositor], } end - Address.upsert_all(addresses_deposit_attributes, record_timestamps: true) if addresses_deposit_attributes.present? + if addresses_deposit_attributes.present? + Address.upsert_all( + addresses_deposit_attributes, + record_timestamps: true, + on_duplicate: Arel.sql( + "dao_deposit = COALESCE(EXCLUDED.dao_deposit, addresses.dao_deposit), " \ + "interest = COALESCE(EXCLUDED.interest, addresses.interest), " \ + "is_depositor = COALESCE(EXCLUDED.is_depositor, addresses.is_depositor)", + ), + ) + end end def update_or_create_udt_accounts!(local_block)