3_0_1-to-3_1_0_upgrade.sql - Potential Bug

mike-h30 wrote on Tuesday, March 16, 2010:

I downloaded the latest CVS today for OpenEMR v3.3.0-dev to begin testing with our data.  Currently we are using OpenEMR 3.0.1.  I ran into a minor issue when running 3_0_1-to-3_1_0_upgrade.sql script.  I received the following error.

**Error

SQL query:

#EndIf
#IfNotRow2D list_options list_id drug_interval option_id 10
INSERT INTO list_options
VALUES (
‘drug_interval’, ‘10’, ‘a.c.’, 10, 0, 0
);

MySQL said: Documentation
#1062 - Duplicate entry ‘drug_interval-10’ for key 1 **

Our database currently has the values option_id = 10 and option_id = 11 in table list_options.   If I delete the records where option_id = 10 and option_id = 11 , then the file 3_0_1-to-3_1_0_upgrade.sql completes without errors.  The remaining upgrade SQL scripts worked fine after that.

-Mike

markleeds wrote on Tuesday, March 16, 2010:

I tried upgrading this past weekend from 2.8.4-dev and had other similar problems.  Going to 3.0 was pretty easy I think.  There was one empty table I had to delete for the first script to work, but no big deal.  Somewhere around the scripts that upgrade past 3.0, I had various problems.  Sometimes a script would lock up and sometimes would run without any problem.  I had problems logging in after upgrading.  This was due to changes in auth.inc.  I copied in an old auth.inc and was able to get in.

Maybe some of the stuff in these scripts is too dependent on the data being just right.

bradymiller wrote on Tuesday, March 16, 2010:

mike-h30,
I am guessing that you are using the sql_upgrade.php script from the 3.0.1 version (the IfNotRow2D function does not exist in that script, so you will attempt to run this code no matter what). If you used the script that you downloaded with the version your uploading to, then should work. Let us know how it goes. Here are some uplaod guides: http://www.openmedsoftware.org/wiki/OpenEMR_Upgrade_Guides

Mark,
Going from sub-3.0 to 3.0 has some special issues.
Depends on following issues:
1) is your admin user name ‘admin’?
2) Is php-gacl installed?
3 is sql-ledger installed?
For a good example of a complete upgrade when php-gacl and sql-ledger are installed, check out how the appliance was upgraded:
http://bradymd.com/appliance/update3/

-brady

Mark,

mike-h30 wrote on Tuesday, March 16, 2010:

Brady,

I do not use the sql_upgrade.php when upgrading.  Instead, I download the newest version (3.3.0) and perform a clean install in my web root.  Then I drop the new openemr database and import my production database (3.0.1).  Then I run each of the SQL scripts accordingly - in my case I did:

1.)  3_0_1-to-3_1_0_upgrade.sql
2.)  3_1_0-to-3_2_0_upgrade.sql
3.)  3_2_0-to-3_3_0_upgrade.sql

-Mike

bradymiller wrote on Tuesday, March 16, 2010:

hey,
That’s incorrect. You need to use the sql_upgrade.php script. This script will automatically load all required upgrade scripts, and there utilizes functions to skip sql code that is not needed (ie. the ‘IfNotRow2D list_options list_id drug_interval option_id 10’ would cause it to skip the contained mysql code in your case). Also, note in 3.1.0 we changed to a pure UTF-8 database (previous to this was a latin1/utf8 database), so ensure you haven’t forced your hybrid database into a utf8 database incorrectly (http://www.openmedsoftware.org/wiki/OpenEMR_UTF-8_Upgrade_Howto). If you follow the posted upgrading instructions (http://www.openmedsoftware.org/wiki/OpenEMR_Upgrade_Guides), you can avoid all these issues.
-brady

mike-h30 wrote on Tuesday, March 16, 2010:

Thanks Brady.  I will re-visit the sql_upgrade.php script.

The reason I avoided it was because I had issues with it when upgrading from 2.83 to 2.90.

-Mike

mike-h30 wrote on Monday, July 19, 2010:

Brady,

I have re-visited this with CVS files from 7/18/10.   This time I ran the sql_upgrade.php script per your recommendation.  Upon running the sql_upgrade.php script in a web browser, I now get this error message.

Processing 3_0_1-to-3_1_0_upgrade.sql …
ALTER TABLE `pnotes` ADD `deleted` TINYINT DEFAULT ‘0’ COMMENT ‘flag indicates note is deleted’
INSERT INTO list_options VALUES (‘lists’ ,‘adjreason’ ,‘Adjustment Reasons’,1,0,0)
ERROR: insert failed: insert into log (date, event, user, groupname, comments, patient_id, success, checksum,crt_user) values ( NOW(), ‘other-insert’, ‘mike’,‘Default’,‘INSERT INTO list_options VALUES (‘lists’ ,‘adjreason’ ,‘Adjustment Reasons’,1,0,0)’,‘0’,‘1’,’’,’’)

Error: Unknown column ‘patient_id’ in ‘field list’

My current OpenEMR version is 3.0.1.  Please advise.

Thanks.

-Mike

bradymiller wrote on Tuesday, July 20, 2010:

hey,

Thanks for reporting this. This bug was reported/fixed in the 3.2 to 4.0 upgrade fix, but obviously will need to be dealt with in the previous version upgrade scripts. Let’s wait to see what Visolve advises:
http://sourceforge.net/tracker/index.php?func=detail&aid=3028385&group_id=60081&atid=493001#

-brady

mike-h30 wrote on Saturday, July 31, 2010:

Brady,

What is the syntax to do what Vosolve proposes below?  Am I modifying globals.php or sql_upgrade.php?  I am going to try testing the upgrade from 3.0.1 to the latest CVS this weekend. Thanks.

-Mike

**
To handle this issue, we can set Audit global variable as disable in the
sql_upgrade.php file under the upgradeFromSqlFile().
Based on our analysis, this doesn’t have any influence since the audit
variable in the globals.php becomes active. We did some high-level test
this too.**

bradymiller wrote on Saturday, July 31, 2010:

hey,
Just committed the fix for this into the CVS. Let us know if it works.
-brady

mike-h30 wrote on Saturday, July 31, 2010:

It works.  No errors.

Updating global configuration defaults…
Database upgrade finished.

I upgraded my DB from 3.0.1.  I am going to proceed with testing.  Thanks Brady! 

-Mike