web stats
Small Bug in mysql-database.sql - Mirth Community

Go Back   Mirth Community > Mirth Connect > Development

Reply
 
Thread Tools Display Modes
  #1  
Old 12-08-2017, 01:26 AM
Felix Nensa Felix Nensa is offline
What's HL7?
 
Join Date: Dec 2017
Posts: 1
Felix Nensa is on a distinguished road
Default Small Bug in mysql-database.sql

When creating a new database on a MySQL/MariaDB cluster you might run into the following error:

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityCons traintViolationException: Cannot add or update a child row: a foreign key constraint fails (`mirth`.`PERSON_PASSWORD`, CONSTRAINT `PERSON_ID_PP_FK` FOREIGN KEY (`PERSON_ID`) REFERENCES `PERSON` (`ID`) ON DELETE CASCADE)

This is because of:

Code:
INSERT INTO PERSON (USERNAME, LOGGED_IN) VALUES('admin', FALSE);
INSERT INTO PERSON_PASSWORD (PERSON_ID, PASSWORD) VALUES(1, 'YzKZIAnbQ5m+3llggrZvNtf5fg69yX7pAplfYg0Dngn/fESH93OktQ==');
Running MySQL/MariaDB in a cluster does not guarantee the autoinc ID of the first row in table PERSON to be 1 as expected by the second insert. E.g. in our 3 node cluster this ID is set to 3.
To fix this just replace the second INSERT with:

Code:
INSERT INTO PERSON_PASSWORD (PERSON_ID, PASSWORD)
  SELECT
    ID,
    'YzKZIAnbQ5m+3llggrZvNtf5fg69yX7pAplfYg0Dngn/fESH93OktQ==' AS PASSWORD
  FROM PERSON 
  WHERE username = 'admin';
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 09:58 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation