insert into amasty_storecredit_customer_balance select balance_id, customer_id, website_id, amount, null as base_currency_code, 0 as subscribe_updates from enterprise_customerbalance; truncate table amasty_storecredit_customer_balance_history; insert into amasty_storecredit_customer_balance_history select history_id, balance_id, updated_at, action, additional_info as operation_name , additional_info as operation_data, additional_info as comment, balance_amount, balance_delta, is_customer_notified as is_notified from enterprise_customerbalance_history; /* moving Updated to a temp action */ update amasty_storecredit_customer_balance_history set action=9 where action=1; /* Used to ACTION_PAY_ORDER */ update amasty_storecredit_customer_balance_history set action=1 where action=3; /* Created to ACTION_ADMIN */ update amasty_storecredit_customer_balance_history set action=3 where action=2; /* Reverted to ACTION_REFUND_ORDER */ update amasty_storecredit_customer_balance_history set action=2 where action=5; /* moving Updated to ACTION_ADMIN */ update amasty_storecredit_customer_balance_history set action=3 where action=9; /* customerbalance to amstorecredit */ update sales_flat_order set base_amstcred_amount = base_customer_balance_amount, amstcred_amount = customer_balance_amount, base_amstcred_amount_invoiced = base_customer_balance_invoiced, amstcred_amount_invoiced = customer_balance_invoiced, base_amstcred_amount_refunded = base_customer_balance_refunded, amstcred_amount_refunded = customer_balance_refunded, base_am_amount_total_refunded = bs_customer_bal_total_refunded, am_amount_total_refunded = customer_bal_total_refunded; update sales_flat_invoice set base_amstcred_amount = base_customer_balance_amount, amstcred_amount = customer_balance_amount; update sales_flat_quote set base_amstcred_amount_used = base_customer_bal_amount_used, amstcred_amount_used = customer_balance_amount_used, amstcred_use_customer_balance = use_customer_balance; update sales_flat_creditmemo set base_amstcred_amount = base_customer_balance_amount, amstcred_amount = customer_balance_amount, base_am_amount_total_refunded = bs_customer_bal_total_refunded, am_amount_total_refunded = customer_bal_total_refunded;