Upgrade_sql bug with 3.2 to 4.0

tmccormi wrote on Wednesday, June 30, 2010:

I posted this bug and a partial fix for it on my github branch.
https://sourceforge.net/tracker/?func=detail&aid=3023188&group_id=60081&atid=493001

Looking for some additional feedback on longer terms solutions.  Brady commented on github but figured I should ask here as well.

Summary: I discovered during several 3.x to 4.0 upgrades that not wrapping every language insert resulted in fails because (horrors) the user had already created some languages and ethrace records…
I am looking for advice on how the current upgrade scripts can handle (or if they should handle) renumbering the elements that already exist the way we did for english and spanish.

tmccormi wrote on Wednesday, June 30, 2010:

This is what Brady had to say:

Interesting issue, especially considering we made it so easy to add these categories with the ajax add button… This is probably why Rod didn’t include the list of states in the upgrade script. You’re above script will at least not break, but still risky potential to add redundant title categories, which could cause a hybrid database for the same “entry”. Could be time for you to join the sql_upgrade.php development darkside and make a new IfNotRow2Dx2 function in sql_upgrade.php:
IfNotRow2Dx2 list_options list_id ethrace option_id withheld title Withheld

(function would basically run through #IfNotRow2D twice with parameter 1 and 2, and then parameter 1 and 3) This would then ensure not adding a list item if the option_id or title already exist.)

I would not worry about the ordering (seq). User can easily fix this.

bradymiller wrote on Friday, July 02, 2010:

Tony,
Have you made the IfNotRow2Dx2 function yet :slight_smile:

tmccormi wrote on Monday, July 05, 2010:

Traveling this week, not sure that’s something I want to take on, in any case.   It whole concept of a meta-language buried in an SQL file just feels wrong to me, somehow.  There has to be a better way to manage SQL upgrades, though, I confess, I can’t think of one right now.    :wink:

Tony

ytiddo wrote on Tuesday, July 06, 2010:

Tony:

At first glance, i thought they were comments. I admit, it was inconcievable to put a language in this place to me, as well…

That said, I have to agree, I can’t envision handling upgrades in a smoother, alternate manner.

(maybe I just like ugly little languages too much…)

bradymiller wrote on Tuesday, July 06, 2010:

Tony (and Justin),

Committed a nice fix here:
http://github.com/openemr/openemr/commit/cd11d8fe4229412e946660f82b3f389f92539c35

Tony, note this kind of stuff would never be possible without a meta-language. Above should avoid duplicates in list items. I wouldn’t worry about the seq (ordering), since you can’t predict this and it is only cosmetic.

-brady