From 178736df065789a4fc4ab78eb5c925d4a293ba82 Mon Sep 17 00:00:00 2001 From: Alexander Lutay Date: Thu, 16 Apr 2015 17:37:58 +0200 Subject: [PATCH] MT#12507 Fix 15139.up: remove hardcoded reference to voip_preference_groups Otherwise 2.8-mr3.8 upgrade failed with error: > Applying revision script /usr/share/ngcp-db-schema/db_scripts/diff/15139.up: > ERROR 1452 (23000) at line 4: Cannot add or update a child row: a foreign key constraint fails > (`provisioning`.`voip_preferences`, CONSTRAINT `vpgid_ref` FOREIGN KEY > (`voip_preference_groups_id`) REFERENCES `voip_preference_groups` (`id`) ON UPDATE CASCADE) It happens because statements are executed on sp1/sp2 (even/odd id's): > mysql> select * from voip_preference_groups; > +----+----------------------------+ > | id | name | > +----+----------------------------+ > | 2 | Call Forwards | > | 4 | Call Blockings | > | 6 | Access Restrictions | > | 8 | Number Manipulations | > | 10 | NAT and Media Flow Control | > | 12 | Remote Authentication | > | 14 | Session Timers | > | 16 | Internals | > | 18 | Cloud PBX | > | 20 | XMPP Settings | > +----+----------------------------+ > 10 rows in set (0.00 sec) Change-Id: I90782a5dae5017f22c240ced15661b88594cff69 --- db_scripts/diff/15139.up | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db_scripts/diff/15139.up b/db_scripts/diff/15139.up index 6f0331ea..3bec2807 100644 --- a/db_scripts/diff/15139.up +++ b/db_scripts/diff/15139.up @@ -1,7 +1,8 @@ use provisioning; set autocommit=0; -insert into voip_preferences values (null, 5, 'rtp_interface', 'RTP interface', 0, 1, 1, 0, 1, 1, 0, now(), 0, 0, 'enum', 0, 'Logical RTP interface to use for media packets'); +select id into @vpg_id from voip_preference_groups where name="NAT and Media Flow Control"; +insert into voip_preferences values (null, @vpg_id, 'rtp_interface', 'RTP interface', 0, 1, 1, 0, 1, 1, 0, now(), 0, 0, 'enum', 0, 'Logical RTP interface to use for media packets'); select last_insert_id() into @ins_id; insert into voip_preferences_enum values (null, @ins_id, 'default', null, 1, 1, 1, 1, null, 1);