Try to fix the lcr_rule key issue #1967

The ley that is tried to be created in 9868.up 
has no group_id field so it won't be applied in 
case you already have two peering groups with 
same peering rules. In case you don't it will 
apply but the resulting 2.6 version won't allow 
you to have different peering groups with same 
peering rules. 

The solution is what follows: We edit the 
existing db scripts to allow upgrades to work 
well. This will make existing 2.6 systems and 
new 2.6 systems to have different db scehmas. 
And the existing ones will be still broken. A new
db rev 10860.up has been created to unify both 
kind of systems (the ones which executed the 
original revs and the ones which excuted the 
edited ones) and it will also fix the existing 
versions as it will be executed in existing 2.6
 systems via postinst script.

Why postinst script? We can't trust users to 
execute update-db-schema as we don't know all 
of them. It's better to handle this automatically.
This postinst addition is being handled by Mika 
in another commit.
2.6
Jon Bonilla 13 years ago
parent f6d2531172
commit cd76e18027

@ -1,6 +1,6 @@
use kamailio;
ALTER TABLE lcr_rule DROP KEY `lcr_id_prefix_from_uri_idx`;
ALTER TABLE lcr_rule ADD UNIQUE KEY `lcr_id_prefix_from_uri_idx` (`lcr_id`,`prefix`,`from_uri`);
#ALTER TABLE lcr_rule ADD UNIQUE KEY `lcr_id_prefix_from_uri_idx` (`lcr_id`,`prefix`,`from_uri`);
ALTER TABLE lcr_gw DROP `group_id`;

@ -1,6 +1,5 @@
use kamailio;
ALTER TABLE lcr_rule DROP KEY `lcr_id_prefix_from_uri_idx`;
ALTER TABLE lcr_rule ADD UNIQUE KEY `lcr_id_prefix_from_uri_idx` (`lcr_id`,`prefix`,`from_uri`, `request_uri`);
#ALTER TABLE lcr_rule DROP KEY `lcr_id_prefix_from_uri_idx`;
ALTER TABLE lcr_rule ADD UNIQUE KEY `lcr_id_prefix_from_uri_idx` (`lcr_id`,`prefix`,`from_uri`, `request_uri`, `group_id`);
ALTER TABLE lcr_gw ADD `group_id` int(11) unsigned NOT NULL AFTER defunct;

@ -0,0 +1,5 @@
use kamailio;
ALTER TABLE lcr_rule DROP KEY `lcr_id_prefix_from_uri_idx`;
ALTER TABLE lcr_rule ADD UNIQUE KEY `lcr_id_prefix_from_uri_idx` (`lcr_id`,`prefix`,`from_uri`, `request_uri`, `group_id`);

@ -0,0 +1,5 @@
use kamailio;
ALTER TABLE lcr_rule DROP KEY `lcr_id_prefix_from_uri_idx`;
ALTER TABLE lcr_rule ADD UNIQUE KEY `lcr_id_prefix_from_uri_idx` (`lcr_id`,`prefix`,`from_uri`, `request_uri`, `group_id`);

@ -4,5 +4,5 @@ ALTER TABLE dispatcher DROP column `attrs`;
ALTER TABLE lcr_gw CHANGE column `gw_name` `gw_name` varchar(128) NOT NULL;
ALTER TABLE lcr_gw ADD column `group_id` int(11) unsigned NOT NULL AFTER defunct;
ALTER TABLE lcr_rule ADD KEY `lcr_id_idx` (`lcr_id`);
ALTER TABLE lcr_rule DROP KEY `lcr_id_prefix_from_uri_idx`;
#ALTER TABLE lcr_rule DROP KEY `lcr_id_prefix_from_uri_idx`;

@ -7,5 +7,7 @@ ALTER TABLE lcr_gw CHANGE column `gw_name` `gw_name` varchar(128) DEFAULT NULL;
ALTER TABLE lcr_gw DROP column `group_id`;
ALTER TABLE lcr_rule DROP KEY lcr_id_idx;
ALTER TABLE lcr_rule ADD UNIQUE KEY `lcr_id_prefix_from_uri_idx` (`lcr_id`,`prefix`,`from_uri`);
#Edited because it breaks upgrade not being really unique between peering groups
#ALTER TABLE lcr_rule ADD UNIQUE KEY `lcr_id_prefix_from_uri_idx` (`lcr_id`,`prefix`,`from_uri`);

Loading…
Cancel
Save