After various updates, I get database migration error

I have an auto updated script which pulls daily from the github 16 branch, and it’s been running perfectly. However, recently I was receiving an error (which caused my script to revert to the pre-updated backup). The error is the following:
Error DB_ERROR_1069: ALTER TABLE llx_takepos_floor_tables ADD UNIQUE(entity,label);
Too many keys specified; max 64 keys allowed

I believe this error comes from the frequent updating, because I have another installation which I only pull as needed, and I was able to update to the most recent commit without issues. What I suspect is that with each migration, an key is added to the table (which will eventually lead to the table having more than 64 keys). However, I’m not sure how to fix this, and it sounds like it will be an issue for anyone eventually given enough database migrations. Any idea on how to resolve this?

Hello,

Most probably you are using MyISAM. If you use InnoDB, it should be Ok

If I’m understanding correctly (I’m not familiar with mysql), this “ADD UNIQUE(entity,label)” command should only occur once (maybe this UNIQUE constraint didn’t exist in v15 and now it’s added for v16?). So, every time I’m “updating” dolibarr (16->16) a new key is added, duplicating the existing UNIQUE constraint for entity and label. I fixed it by logging into my mysql and

ALTER TABLE llx_takepos_floor_tables
DROP INDEX entity_63;

I actually went ahead and did the same thing for entity_2 → entity_63 since they are all duplicated constraints. I saw that on the mysql migration there are a couple of ADD UNIQUE, but none of them are for two columns, so I’ll eventually get the same problem for the all these ADD UNIQUE. In the meantime I’ll reduce my update frequency to weekly so that I run into these problems less frequently. (Edit: Strikeout, not sure if this is correct because for two columns it seems it’s still one key.)

All tables are using InnoDB, checked with SHOW TABLE STATUS

It’s my understanding that it’s actually a bug from the update script, shouldn’t:

Request 247 sql='ALTER TABLE llx_takepos_floor_tables ADD UNIQUE(entity,label);'

actually be:

Request 247 sql='ALTER TABLE llx_takepos_floor_tables ADD UNIQUE MISSINGKEYNAME (entity,label);'

where MISSINGKEYNAME is the name for the key for this UNIQUE constraint.

This isn’t a problem anymore in the current version of 16.0