Composite index name too long
See original GitHub issueSo I was creating a table tonight with 6 fields put into a compound index per the docs.
field: {type:Sequelize.STRING(34), unique:'main'},
another_field: {type:Sequelize.STRING(34), unique:'main'},
a_date_field: {type:Sequelize.STRING(34), unique:'main'},
yet_another_field: {type:Sequelize.STRING(34), unique:'main'},
almost_done_field: {type:Sequelize.STRING(34), unique:'main'},
last_field: {type:Sequelize.STRING(34), unique:'main'}
I’m getting an error from MySQL. ER_TOO_LONG_IDENT “Identifier name is too long”.
Sequelize is combining my field names to create an index name rather than using the ‘main’ string I’m providing.
Is there a way to provide the index name to avoid this issue?
Issue Analytics
- State:
- Created 9 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Index name too long attachinary/postgresql - Stack Overflow
You are getting the error due to this line in the migration: t.references :attachinariable, polymorphic: true. By default index is true.
Read more >Migration index too long? Choose the name yourself!
Choose the name yourself! Migrations are a great way of building database schema, but sometimes it's harder to deal with more than just...
Read more >Specify Name for text Index — MongoDB Manual
Starting in version 4.2, for featureCompatibilityVersion set to "4.2" or greater, MongoDB removes the Index Name Length limit of 127 byte maximum.
Read more >Indexes for search performance - Cypher Manual - Neo4j
An index created on more than one property for any given label or relationship type is called a composite index. Differences in the...
Read more >Example: Creating a Composite, Unique Index
index -name specifies the name of the index to be created. If you are creating an index on one column only, then index-name...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Please reopen this. This is a bug in
lib/associations/belongs-to-many.js
,injectAttributes()
.https://github.com/sequelize/sequelize/blob/f36db54dd5b031427fd8c52296c614c56421e4ba/lib/associations/belongs-to-many.js#L262
This line creates an index name for a BelongsToMany table, and if the name is longer than 64 characters it will fail on MySQL. On PostgreSQL I believe the name will be truncated to 63 chars, which also is not desirable.
Ideally I’d have the option to specify the index name myself.
uniqueKey
name can be overridden now https://github.com/sequelize/sequelize/pull/9914