From b585cdf12f6e3f144681d2030be59874e7b96f61 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Wed, 20 Mar 2013 21:16:43 +0000 Subject: [PATCH] Split fee-related columns into source and destination. Fees applied to the caller for a specific destination go to source_* (same behavior as before), fees applied to the callee for the same destination go to destination_*. --- db_scripts/diff/13219_not_replicated.down | 37 +++++++++++++++++++++++ db_scripts/diff/13219_not_replicated.up | 37 +++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 db_scripts/diff/13219_not_replicated.down create mode 100644 db_scripts/diff/13219_not_replicated.up diff --git a/db_scripts/diff/13219_not_replicated.down b/db_scripts/diff/13219_not_replicated.down new file mode 100644 index 00000000..30de7cf4 --- /dev/null +++ b/db_scripts/diff/13219_not_replicated.down @@ -0,0 +1,37 @@ +-- 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 source_carrier_cost carrier_cost decimal(10,2) DEFAULT NULL, + CHANGE COLUMN source_reseller_cost reseller_cost decimal(10,2) DEFAULT NULL, + CHANGE COLUMN source_customer_cost customer_cost decimal(10,2) DEFAULT NULL, + CHANGE COLUMN source_carrier_free_time carrier_free_time int(10) unsigned DEFAULT NULL, + CHANGE COLUMN source_reseller_free_time reseller_free_time int(10) unsigned DEFAULT NULL, + CHANGE COLUMN source_customer_free_time customer_free_time int(10) unsigned DEFAULT NULL, + CHANGE COLUMN source_carrier_billing_fee_id carrier_billing_fee_id int(11) unsigned DEFAULT NULL, + CHANGE COLUMN source_reseller_billing_fee_id reseller_billing_fee_id int(11) unsigned DEFAULT NULL, + CHANGE COLUMN source_customer_billing_fee_id customer_billing_fee_id int(11) unsigned DEFAULT NULL, + CHANGE COLUMN source_carrier_billing_zone_id carrier_billing_zone_id int(11) unsigned DEFAULT NULL, + CHANGE COLUMN source_reseller_billing_zone_id reseller_billing_zone_id int(11) unsigned DEFAULT NULL, + CHANGE COLUMN source_customer_billing_zone_id customer_billing_zone_id int(11) unsigned DEFAULT NULL, + DROP COLUMN destination_carrier_cost, + DROP COLUMN destination_reseller_cost, + DROP COLUMN destination_customer_cost, + DROP COLUMN destination_carrier_free_time, + DROP COLUMN destination_reseller_free_time, + DROP COLUMN destination_customer_free_time, + DROP COLUMN destination_carrier_billing_fee_id, + DROP COLUMN destination_reseller_billing_fee_id, + DROP COLUMN destination_customer_billing_fee_id, + DROP COLUMN destination_carrier_billing_zone_id, + DROP COLUMN destination_reseller_billing_zone_id, + DROP COLUMN destination_customer_billing_zone_id; + +COMMIT; diff --git a/db_scripts/diff/13219_not_replicated.up b/db_scripts/diff/13219_not_replicated.up new file mode 100644 index 00000000..84384619 --- /dev/null +++ b/db_scripts/diff/13219_not_replicated.up @@ -0,0 +1,37 @@ +-- 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;