FreeHealth / freehealth

Free and open source Electronic Health Record
https://freehealth.io
Other
44 stars 16 forks source link

MySQL / MariaDB error on recent versions of Ubuntu: "Index column size too large" #96

Closed jeromecc closed 6 years ago

jeromecc commented 7 years ago

"SQL Error: 1709 QMYSQL: Unable to execute query Index column size too large. The maximum column size is 767 bytes."

The new default trendy character set for My/Maria is utf8mb4. It allows emojis and a few mathematicals symbols that are not present in the 3 bytes MySQL style "utf8".

It requires 4 bytes instead of 3 bytes for the old MySQL "utf8" character set. 767/4 is slightl over 190. fhio code defined FieldIsShortText as VARCHAR(200). Trying to create an index on those columns will fail and the tables will not be created. These index columns should be resized to 190. Here are the 6 VARCHAR(200) columns of interest:

Db fmf_agenda Clear

Db: fmf_alerts

Db: fmf_categories

Db: fmf_dosages: Clear

Db: fmf_episodes

Db: fmf_patients

Db: fmf_pmh Clear

Db: fmf_templates Clear

Db: fmf_users

Db: fmf_xmlforms

Solution: user only the first n letters: CREATE INDEX PATIENT_IDENTITY__NAME ON PATIENT_IDENTITY (NAME(10));

jeromecc commented 7 years ago

CREATE INDEX has a FULLTEXT option but it is available only for MyISAM in MySQL 5.5. Lots of distros still use MySQL 5.5 (eg Ubuntu 14.04, Debian Jessie).

I don't think we should break things for those widely used Linux distributions versions.

jeromecc commented 7 years ago

Name of indexes to drop: index.field.tableName + "__" + index.field.fieldName

jeromecc commented 7 years ago

Done for alerts database commit f1391775d8137f24a772cec6c60d5efc46152a9c

jeromecc commented 7 years ago

Done for category database with 479db0820b216060aece50d2ed307a9cf5341592

jeromecc commented 6 years ago

Done for episodes database with commit https://github.com/FreeHealth/freehealth/commit/298ca9f80a0e6804303b9c18819f537708f1f8fb

jeromecc commented 6 years ago

Done for database patients with https://github.com/FreeHealth/freehealth/commit/f1391775d8137f24a772cec6c60d5efc46152a9c

jeromecc commented 6 years ago

Fix int UserBase::getMaxLinkId()

table LK_USER:

jeromecc commented 6 years ago

database users: done with commit 4a23526

jeromecc commented 6 years ago

database xmlforms: done with commit 419423655669cfed9ab30fa05daf08d9d4329bed

jeromecc commented 6 years ago

merged to master