I'm not sure if it's actually called "length constraint", but I have a SQL statement that works when testing in a local docker container with mysql:
create unique index _uq_data on data(question_id, reply_id, text(50));
The constraint/length notation (50)
is required since the TEXT field is variable length and may make the key too long. When creating a Flask migration for this I tried:
op.create_unique_constraint('_data_uc', 'data', ['question_id', 'reply_id', 'text(50)'])
But the SQL that Alembic generates for this quotes the whole last field:
ALTER TABLE data ADD CONSTRAINT _data_uc UNIQUE (question_id, reply_id, `text(50)`);
which gives the error
ERROR 1072 (42000): Key column 'text(50)' doesn't exist in table
How do I get this emitted as 'text'(50)
rather than 'text(50)'
?