|go ahead... be a heretic|
DBIx::Class unique constraint with limited key lengthby chrestomanci (Priest)
|on Aug 21, 2015 at 09:54 UTC||Need Help??|
chrestomanci has asked for the wisdom of the Perl Monks concerning the following question:
DBIx::Class unique constraint with limited key length
Greetings wise brothers. I seek your wisdom on how to be confident that all are different without the need to remember every part.
I am working DBIx::Class, and I would like to add a unique constraint of limited key length to a much longer varchar column
My DBIC schema definition code looks like this:
This generates MySQL like this:
The problem is, that when I deploy, MySQL correctly reports that you can not have a unique constraint on a varchar that long without limiting the key length. What I would like to do, is have it generate SQL like UNIQUE `classification_rules_path` (path(250)) but I cannot work out how.
I have already stepped through the add_unique_constraint code in DBIx::Class::ResultSource to try to find an undocumented feature or hook I can use and also added breakpoints in SQL::Translator::Producer::MySQL to try and spot where the SQL is being generated from the other end.
Is there another solution to this? Is there a hook to add literal SQL to the definition for my table?