From 4e028747332869115ecce16214d3c7099655af96 Mon Sep 17 00:00:00 2001 From: Jenkins Git User Date: Mon, 18 May 2015 01:13:21 +0200 Subject: [PATCH] MT#12643 billing network, profile packages Change-Id: Ic904086fac4ac5b76e5dd5174b86fa09d838526f --- db_scripts/diff/15165.down | 2 +- db_scripts/diff/15165.up | 2 +- db_scripts/diff/15167.down | 2 - db_scripts/diff/15167.up | 2 - db_scripts/diff/15170.up | 1 - db_scripts/diff/15171.down | 13 ++++++ db_scripts/diff/15171.up | 90 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 105 insertions(+), 7 deletions(-) create mode 100644 db_scripts/diff/15171.down create mode 100644 db_scripts/diff/15171.up diff --git a/db_scripts/diff/15165.down b/db_scripts/diff/15165.down index a62e29e7..18e6c917 100644 --- a/db_scripts/diff/15165.down +++ b/db_scripts/diff/15165.down @@ -5,4 +5,4 @@ ALTER TABLE billing_profiles DROP COLUMN fraud_use_reseller_rates; DROP INDEX said_stime_idx ON accounting.cdr; -commit; +commit; \ No newline at end of file diff --git a/db_scripts/diff/15165.up b/db_scripts/diff/15165.up index a65f30be..2f0612a3 100644 --- a/db_scripts/diff/15165.up +++ b/db_scripts/diff/15165.up @@ -5,4 +5,4 @@ ALTER TABLE billing_profiles ADD COLUMN fraud_use_reseller_rates tinyint(3) unsi CREATE INDEX said_stime_idx ON accounting.cdr (source_account_id, start_time); -commit; +commit; \ No newline at end of file diff --git a/db_scripts/diff/15167.down b/db_scripts/diff/15167.down index 02f2afbb..6c0281ad 100644 --- a/db_scripts/diff/15167.down +++ b/db_scripts/diff/15167.down @@ -8,5 +8,3 @@ drop table if exists billing_fees_raw; drop procedure if exists fill_billing_fees; COMMIT; - - diff --git a/db_scripts/diff/15167.up b/db_scripts/diff/15167.up index ce539d82..a1231678 100644 --- a/db_scripts/diff/15167.up +++ b/db_scripts/diff/15167.up @@ -58,5 +58,3 @@ CALL fill_billing_fees(null); COMMIT; - - diff --git a/db_scripts/diff/15170.up b/db_scripts/diff/15170.up index 1ed8e55e..f0098c50 100644 --- a/db_scripts/diff/15170.up +++ b/db_scripts/diff/15170.up @@ -5,4 +5,3 @@ INSERT INTO voip_preferences_enum (preference_id, label, value, usr_pref, dom_pref, contract_pref, prof_pref, peer_pref, default_val) VALUES (@pref_id, 'If both parties are on public IP', 'both_public', 1, 1, 1, 0, 0, 0); - diff --git a/db_scripts/diff/15171.down b/db_scripts/diff/15171.down new file mode 100644 index 00000000..26eab64c --- /dev/null +++ b/db_scripts/diff/15171.down @@ -0,0 +1,13 @@ +USE billing; + +ALTER TABLE `contracts` DROP FOREIGN KEY `c_package_ref`; +ALTER TABLE `contracts` DROP `profile_package_id`; +DROP TABLE IF EXISTS `package_profile_sets`; +#DROP TABLE IF EXISTS `package_topups`; +DROP TABLE IF EXISTS `profile_packages`; + +#DROP TRIGGER IF EXISTS `bnb_net_from_to_trig`; +ALTER TABLE `billing_mappings` DROP FOREIGN KEY `bm_network_ref`; +ALTER TABLE `billing_mappings` DROP `network_id`; +DROP TABLE IF EXISTS `billing_network_blocks`; +DROP TABLE IF EXISTS `billing_networks`; \ No newline at end of file diff --git a/db_scripts/diff/15171.up b/db_scripts/diff/15171.up new file mode 100644 index 00000000..2f5a2538 --- /dev/null +++ b/db_scripts/diff/15171.up @@ -0,0 +1,90 @@ +USE billing; + +CREATE TABLE `billing_networks` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `reseller_id` int(11) unsigned DEFAULT NULL, + `name` varchar(255) NOT NULL, + `description` varchar(255) NOT NULL, + `status` enum('active','terminated') NOT NULL DEFAULT 'active', + PRIMARY KEY (`id`), + UNIQUE KEY `bn_resname_idx` (`reseller_id`,`name`), + CONSTRAINT `bn_reseller_ref` FOREIGN KEY (`reseller_id`) REFERENCES `resellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `billing_network_blocks` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `network_id` int(11) unsigned NOT NULL, + `ip` varchar(39) NOT NULL, + `mask` tinyint(1) unsigned DEFAULT NULL, + `_ipv4_net_from` varbinary(4) DEFAULT NULL, + `_ipv4_net_to` varbinary(4) DEFAULT NULL, + `_ipv6_net_from` varbinary(16) DEFAULT NULL, + `_ipv6_net_to` varbinary(16) DEFAULT NULL, + PRIMARY KEY (`id`), + INDEX `bnb_ipv4_from_idx` (`_ipv4_net_from`), + INDEX `bnb_ipv4_to_idx` (`_ipv4_net_to`), + INDEX `bnb_ipv6_from_idx` (`_ipv6_net_from`), + INDEX `bnb_ipv6_to_idx` (`_ipv6_net_to`), + CONSTRAINT `bnb_network_ref` FOREIGN KEY (`network_id`) REFERENCES `billing_networks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `billing_mappings` ADD `network_id` int(11) unsigned DEFAULT NULL AFTER `product_id`; +#set null or delete? +ALTER TABLE `billing_mappings` ADD CONSTRAINT `bm_network_ref` FOREIGN KEY (`network_id`) REFERENCES `billing_networks` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +CREATE TABLE `profile_packages` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `reseller_id` int(11) unsigned DEFAULT NULL, + `name` varchar(255) NOT NULL, + `description` varchar(255) NOT NULL, + `status` enum('active','terminated') NOT NULL DEFAULT 'active', + + `initial_balance` double NOT NULL DEFAULT '0', + `service_charge` double NOT NULL DEFAULT '0', + `balance_interval_unit` enum('day','week','month') NOT NULL DEFAULT 'month', + `balance_interval_value` int(3) unsigned NOT NULL DEFAULT '1', + `balance_interval_start_mode` enum('create','1st','topup') NOT NULL DEFAULT 'create', + + `carry_over_mode` enum('carry_over','carry_over_timely','discard') NOT NULL DEFAULT 'carry_over', + #`timely_carry_over_mode` enum('carry_over','discard') NOT NULL DEFAULT 'carry_over', + `timely_duration_unit` enum('day','week','month') DEFAULT NULL, + `timely_duration_value` int(3) unsigned DEFAULT NULL, + `notopup_discard_intervals` int(3) unsigned DEFAULT NULL, + + `underrun_lock_threshold` double DEFAULT NULL, #unsigned + `underrun_lock_level` tinyint(3) DEFAULT NULL, + `underrun_profile_threshold` double DEFAULT NULL, #unsigned + + `topup_lock_level` tinyint(3) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `pp_resname_idx` (`reseller_id`,`name`), + CONSTRAINT `pp_reseller_ref` FOREIGN KEY (`reseller_id`) REFERENCES `resellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +#CREATE TABLE `package_topups` ( +# `id` int(11) unsigned NOT NULL AUTO_INCREMENT, +# `package_id` int(11) unsigned NOT NULL, +# `amount` double NOT NULL, +# PRIMARY KEY (`id`), +# UNIQUE KEY `pt_packamount_idx` (`package_id`,`amount`), +# CONSTRAINT `pt_package_ref` FOREIGN KEY (`package_id`) REFERENCES `profile_packages` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +#) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `package_profile_sets` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `package_id` int(11) unsigned NOT NULL, #DEFAULT NULL, + #`topup_id` int(11) unsigned DEFAULT NULL, + `discriminator` enum('initial','underrun','topup') NOT NULL, + `profile_id` int(11) unsigned NOT NULL, + `network_id` int(11) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + INDEX `pps_packdiscr_idx` (`package_id`,`discriminator`), + #INDEX `pps_topupdiscr_idx` (`topup_id`,`discriminator`), + CONSTRAINT `pps_package_ref` FOREIGN KEY (`package_id`) REFERENCES `profile_packages` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + #CONSTRAINT `pps_topup_ref` FOREIGN KEY (`package_id`) REFERENCES `package_topups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `pps_profile_ref` FOREIGN KEY (`profile_id`) REFERENCES `billing_profiles` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT `pps_network_ref` FOREIGN KEY (`network_id`) REFERENCES `billing_networks` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `contracts` ADD `profile_package_id` int(11) unsigned DEFAULT NULL AFTER `order_id`; +ALTER TABLE `contracts` ADD CONSTRAINT `c_package_ref` FOREIGN KEY (`profile_package_id`) REFERENCES `profile_packages` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;