The current column is a VARCHAR(255) NOT NULL, so how do I change it to TEXT NOT NULL?
NOTE: The column intended to be changed its property type is a UNIQUE KEY comb
I had exactly the same problem.
I added a new char(32) column (I called it hash
and added a unique index on it) and two triggers.
delimiter |
CREATE TRIGGER insert_set_hash
BEFORE INSERT ON my_table_name
FOR EACH ROW BEGIN
SET NEW.hash = MD5(NEW.my_text);
END; |
CREATE TRIGGER update_set_hash
BEFORE UPDATE ON my_table_name
FOR EACH ROW BEGIN
SET NEW.hash = MD5(NEW.my_text);
END; |
delimiter ;
By using the triggers and adding a UNIQUE index on hash you can be sure that the hash values will always be up-to-date and unique.