sync({alter: true}) throws "Too many keys specified"

See original GitHub issue

This issue is related to #9536

What are you doing?

await sequelize.sync({ alter: true, force: false });

What do you expect to happen?

Sequelize to sync successfully.

What is actually happening?

I get this error: SequelizeDatabaseError: Too many keys specified; max 64 keys allowed. This happens I guess after 64 times of restarting the application.

How did I workaround

There are few things that I can do

  1. set force: true. This is not practical for production environment
  2. set alter: false. This is not practical when my definitions change
  3. set MYSQL key limit, which is makes it hard for cross platform compatibility
  4. delete all tables, which defeats the point of use alter. I guess alter creates some indexes which make

Dialect: mysql Database version: XXX Sequelize version: 4.37.10 Tested with latest release: Yes (If yes, specify that version)

Note : Your issue may be ignored OR closed by maintainers if it’s not tested against latest version OR does not follow issue template.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:11
  • Comments:36 (3 by maintainers)

github_iconTop GitHub Comments

44reactions
codextechcommented, Jul 17, 2020

old sequelize use email:{type: Sequelize.STRING, unique: true} Now, email:{type: Sequelize.STRING, unique:‘email’} this will fix the issue.

21reactions
cribcutkirancommented, Jan 11, 2019

Here’s workaround that seems to fix it. If you use the approach documented here, it maintains the same index rather than adding a new one each time sequelize syncs. So instead of: sequelize.define('user', {email: {type: Sequelize.STRING, unique:true}}) use sequelize.define('user', {email: Sequelize.STRING}, {indexes:[{unique:true, fields: ['email']}]})

Read more comments on GitHub >

github_iconTop Results From Across the Web

db.sync({alter:true}).then(); in sequelize node.js express app
The workaround solution is to use string instead of a boolean,. So the old: column: {unique:true, }. becomes: column:{unique:'column'}.
Read more >
SearchApiException Too many keys specified; max 64 keys ...
I created a new node index with a lot of fields. When I try to index, I get the message "Couldn't index items....
Read more >
Model Basics | Sequelize
User.sync({ alter: true }) - This checks what is the current state of the table in the database (which columns it has, what...
Read more >
MariaDB Error Codes
Shared MariaDB/MySQL error codes; MariaDB-specific error codes ... 1069, 42000, ER_TOO_MANY_KEYS, Too many keys specified; max %d keys allowed.
Read more >
Hive DDL - Confluence Mobile - Apache Software Foundation
Its recommended that MANAGEDLOCATION be within metastore.warehouse.dir so all ... properties with the new set of properties specified in the ALTER DDL.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found