# After upgrading to 5 Error: Specified key was too long; max key length is 1000 bytes

**URL:** <https://community.open-emr.org/t/after-upgrading-to-5-error-specified-key-was-too-long-max-key-length-is-1000-bytes/8200>\
**Category:** Management and Administration\
**Created:** [March 7, 2017, 8:28pm UTC](https://community.open-emr.org/t/after-upgrading-to-5-error-specified-key-was-too-long-max-key-length-is-1000-bytes/8200 "2017-03-07T20:28:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [March 7, 2017, 8:28pm UTC](https://community.open-emr.org/t/after-upgrading-to-5-error-specified-key-was-too-long-max-key-length-is-1000-bytes/8200/1 "2017-03-07T20:28:06Z")

</div>

**[ajperezcrespo](https://sourceforge.net/u/ajperezcrespo/)** wrote on [Tuesday, March 07, 2017](https://sourceforge.net/p/openemr/discussion/202505/thread/fb0882fc/#972e):

_Just upgraded from 4.2.1 to 5.0 using the deb file. All seemed fine and dandy until I logged in.  
First error was this._

ERROR: insert failed: insert into log ( date, event,category, user, groupname, success, comments, crt\_user, patient\_id) values ( NOW(), ‘login’,‘login’,‘admin’,‘Default’,‘1’,‘success: 192.168.1.100’,NULL,NULL)

**Error: Unknown column ‘category’ in 'field list’**  
/var/www/openemr/library/log.inc at 45:sqlInsertClean\_audit  
/var/www/openemr/library/authentication/login\_operations.php at 116:newEvent(login,admin,Default,1,success: 192.168.1.100)  
/var/www/openemr/library/auth.inc at 50:validate\_user\_password(admin,Default)  
/var/www/openemr/interface/globals.php at 449:include\_once(/var/www/openemr/library/auth.inc)  
/var/www/openemr/interface/main/main\_screen.php at 25:require\_once(/var/www/openemr/interface/globals.php)

_I then ran the sql\_upgrade.php_

Table version migrated to InnoDB.  
Table x12\_partners migrated to InnoDB.  
CREATE TABLE `valueset` ( `nqf_code` varchar(255) NOT NULL DEFAULT ‘’, `code` varchar(255) NOT NULL DEFAULT ‘’, `code_system` varchar(255) NOT NULL DEFAULT ‘’, `code_type` varchar(255) DEFAULT NULL, `valueset` varchar(255) NOT NULL DEFAULT ‘’, `description` varchar(255) DEFAULT NULL, `valueset_name` varchar(500) DEFAULT NULL, PRIMARY KEY (`nqf_code`,`code`,`valueset`)) ENGINE=InnoDB

ERROR: query failed: CREATE TABLE `valueset` ( `nqf_code` varchar(255) NOT NULL DEFAULT ‘’, `code` varchar(255) NOT NULL DEFAULT ‘’, `code_system` varchar(255) NOT NULL DEFAULT ‘’, `code_type` varchar(255) DEFAULT NULL, `valueset` varchar(255) NOT NULL DEFAULT ‘’, `description` varchar(255) DEFAULT NULL, `valueset_name` varchar(500) DEFAULT NULL, PRIMARY KEY (`nqf_code`,`code`,`valueset`)) ENGINE=InnoDB  
**Error: Specified key was too long; max key length is 1000 bytes**  
/var/www/openemr/library/sql\_upgrade\_fx.php at 675:sqlStatement  
/var/www/openemr/sql\_upgrade.php at 56:upgradeFromSqlFile(4\_2\_2-to-5\_0\_0\_upgrade.sql)

Ubuntu 14.04 LTS  
MySQL 5.5.54  
Apache 2.4.7  
PHP 5.5.9

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [March 8, 2017, 12:38am UTC](https://community.open-emr.org/t/after-upgrading-to-5-error-specified-key-was-too-long-max-key-length-is-1000-bytes/8200/2 "2017-03-08T00:38:51Z")

</div>

**[aperezcrespo](https://sourceforge.net/u/aperezcrespo/)** wrote on [Wednesday, March 08, 2017](https://sourceforge.net/p/openemr/discussion/202505/thread/fb0882fc/#9794):

Had to manually create the table valueset. Odd.

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [March 8, 2017, 7:47am UTC](https://community.open-emr.org/t/after-upgrading-to-5-error-specified-key-was-too-long-max-key-length-is-1000-bytes/8200/3 "2017-03-08T07:47:38Z")

</div>

**[bradymiller](https://sourceforge.net/u/bradymiller/)** wrote on [Wednesday, March 08, 2017](https://sourceforge.net/p/openemr/discussion/202505/thread/fb0882fc/#41a3):

Hi Alfonso,

Thanks for the report.

This is a concerning bug. I didn’t pick this up when I tested upgrading of the package (I tested it on Ubuntu 14.04). I’ll test this again, and if confirm this, then will push us to need to fix this issue (make the keys smaller), place in patch, and release new packages.

Either way, we need to make the keys smaller via the upgrade/patch mechanism (this mechanism already exists, since we actually had to do this many years ago when we migrated to utf8 since utf8 makes the keys larger than the older latin1).

I’ll keep you updated on the progress of this here.

-brady  
[OpenEMR](http://www.open-emr.org/)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [March 8, 2017, 7:51am UTC](https://community.open-emr.org/t/after-upgrading-to-5-error-specified-key-was-too-long-max-key-length-is-1000-bytes/8200/4 "2017-03-08T07:51:51Z")

</div>

**[bradymiller](https://sourceforge.net/u/bradymiller/)** wrote on [Wednesday, March 08, 2017](https://sourceforge.net/p/openemr/discussion/202505/thread/fb0882fc/#20b9):

Just posted this issue on github here(it’s easier for me to track the progress there):

> <https://github.com/openemr/openemr/issues/532>
