'How to add unique and index to a TEXT column without hashing

Everything works, with some "problems" and now after database upgrade it doesn't.

I have a table like this

it-IT (text) en-GB (text)
foo foo
bar bar

Since I was using mysql 5.7 I was able to give unique and index to the it-IT, if I truncate the table I getted a lots of error, but repalcing data everything works very well.

After some debug, I decide to switch to current server sql version (MariaDb 10.3.34 with InnoDb) and creating the same database I'm not able to add to the it-IT columns as unique and adding an index on it.

#1170 - BLOB/TEXT column 'it-IT' used in key specification without a key length

Sincerly from the beginning I avoided to hashing string to avoid (low probability) collision, and to make the app faster, and cause I would like to find direclty the string and not the hash during my flow

The text is not soo much longher, but sometimes exceded the 255 chars, I think the only solution is getting the md5 but I hope is some better solutions.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source