-- We explicitely don't replicate this statement in order
-- to perform the query only on the corresponding standby
-- node, and we make sure to execute it on both nodes.
-- The reason is that this statement might take quite long
-- and would lock the cdr table on the active node.

USE accounting;
SET AUTOCOMMIT=0;
SET sql_log_bin=0;

ALTER TABLE cdr 
  CHANGE COLUMN carrier_cost source_carrier_cost decimal(10,2) DEFAULT NULL,
  CHANGE COLUMN reseller_cost source_reseller_cost decimal(10,2) DEFAULT NULL,
  CHANGE COLUMN customer_cost source_customer_cost decimal(10,2) DEFAULT NULL,
  CHANGE COLUMN carrier_free_time source_carrier_free_time int(10) unsigned DEFAULT NULL,
  CHANGE COLUMN reseller_free_time source_reseller_free_time int(10) unsigned DEFAULT NULL,
  CHANGE COLUMN customer_free_time source_customer_free_time int(10) unsigned DEFAULT NULL,
  CHANGE COLUMN carrier_billing_fee_id source_carrier_billing_fee_id int(11) unsigned DEFAULT NULL,
  CHANGE COLUMN reseller_billing_fee_id source_reseller_billing_fee_id int(11) unsigned DEFAULT NULL,
  CHANGE COLUMN customer_billing_fee_id source_customer_billing_fee_id int(11) unsigned DEFAULT NULL,
  CHANGE COLUMN carrier_billing_zone_id source_carrier_billing_zone_id int(11) unsigned DEFAULT NULL,
  CHANGE COLUMN reseller_billing_zone_id source_reseller_billing_zone_id int(11) unsigned DEFAULT NULL,
  CHANGE COLUMN customer_billing_zone_id source_customer_billing_zone_id int(11) unsigned DEFAULT NULL,
  ADD COLUMN destination_carrier_cost decimal(10,2) DEFAULT NULL AFTER source_customer_billing_zone_id,
  ADD COLUMN destination_reseller_cost decimal(10,2) DEFAULT NULL AFTER destination_carrier_cost,
  ADD COLUMN destination_customer_cost decimal(10,2) DEFAULT NULL AFTER destination_reseller_cost,
  ADD COLUMN destination_carrier_free_time int(10) unsigned DEFAULT NULL AFTER destination_customer_cost,
  ADD COLUMN destination_reseller_free_time int(10) unsigned DEFAULT NULL AFTER destination_carrier_free_time,
  ADD COLUMN destination_customer_free_time int(10) unsigned DEFAULT NULL AFTER destination_reseller_free_time,
  ADD COLUMN destination_carrier_billing_fee_id int(11) unsigned DEFAULT NULL AFTER destination_customer_free_time,
  ADD COLUMN destination_reseller_billing_fee_id int(11) unsigned DEFAULT NULL AFTER destination_carrier_billing_fee_id,
  ADD COLUMN destination_customer_billing_fee_id int(11) unsigned DEFAULT NULL AFTER destination_reseller_billing_fee_id,
  ADD COLUMN destination_carrier_billing_zone_id int(11) unsigned DEFAULT NULL AFTER destination_customer_billing_fee_id,
  ADD COLUMN destination_reseller_billing_zone_id int(11) unsigned DEFAULT NULL AFTER destination_carrier_billing_zone_id,
  ADD COLUMN destination_customer_billing_zone_id int(11) unsigned DEFAULT NULL AFTER destination_reseller_billing_zone_id;

COMMIT;
