Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runmigration fails with UNIQUE KEY PRIMARY index #85

Open
axlwild opened this issue Dec 19, 2020 · 0 comments
Open

runmigration fails with UNIQUE KEY PRIMARY index #85

axlwild opened this issue Dec 19, 2020 · 0 comments

Comments

@axlwild
Copy link

axlwild commented Dec 19, 2020

If I add explicitly the primary index I get an error of wrong name.

Example:
{ fn: "addIndex", params: [ "admins", [{ "name": "id" }], { "indexName": "PRIMARY", "name": "PRIMARY", "indicesType": "UNIQUE", "type": "UNIQUE" } ] },

Error:
Executing (default): ALTER TABLE adminsADD UNIQUE INDEXPRIMARY (id) DatabaseError [SequelizeDatabaseError]: Incorrect index name 'PRIMARY' at Query.formatError (/node_modules/sequelize/lib/dialects/mysql/query.js:239:16) at Query.run (/node_modules/sequelize/lib/dialects/mysql/query.js:54:18) at processTicksAndRejections (internal/process/task_queues.js:97:5) { parent: Error: Incorrect index name 'PRIMARY' at Packet.asError (/node_modules/mysql2/lib/packets/packet.js:712:17) at Query.execute (/node_modules/mysql2/lib/commands/command.js:28:26) at Connection.handlePacket (/node_modules/mysql2/lib/connection.js:425:32) at PacketParser.onPacket (/node_modules/mysql2/lib/connection.js:75:12) at PacketParser.executeStart (/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.<anonymous> (/node_modules/mysql2/lib/connection.js:82:25) at Socket.emit (events.js:314:20) at addChunk (_stream_readable.js:298:12) at readableAddChunk (_stream_readable.js:273:9) at Socket.Readable.push (_stream_readable.js:214:10) at TCP.onStreamRead (internal/stream_base_commons.js:188:23) { code: 'ER_WRONG_NAME_FOR_INDEX', errno: 1280, sqlState: '42000', sqlMessage: "Incorrect index name 'PRIMARY'", sql: 'ALTER TABLE adminsADD UNIQUE INDEXPRIMARY (id)', parameters: undefined }, original: Error: Incorrect index name 'PRIMARY' at Packet.asError (/node_modules/mysql2/lib/packets/packet.js:712:17) at Query.execute (/node_modules/mysql2/lib/commands/command.js:28:26) at Connection.handlePacket (/node_modules/mysql2/lib/connection.js:425:32) at PacketParser.onPacket (/node_modules/mysql2/lib/connection.js:75:12) at PacketParser.executeStart (/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.<anonymous> (/node_modules/mysql2/lib/connection.js:82:25) at Socket.emit (events.js:314:20) at addChunk (_stream_readable.js:298:12) at readableAddChunk (_stream_readable.js:273:9) at Socket.Readable.push (_stream_readable.js:214:10) at TCP.onStreamRead (internal/stream_base_commons.js:188:23) { code: 'ER_WRONG_NAME_FOR_INDEX', errno: 1280, sqlState: '42000', sqlMessage: "Incorrect index name 'PRIMARY'", sql: 'ALTER TABLE adminsADD UNIQUE INDEXPRIMARY (id)', parameters: undefined }, sql: 'ALTER TABLE adminsADD UNIQUE INDEXPRIMARY (id)', parameters: undefined }

When I clean all 'PRIMARY' records on migration, I don't get that error.

And I think it should be repaired because I'm using this tool with sequelize-auto to generate the models, and it generates this index explicitly. So both wouldn't be compatible.

I'm using this version: [email protected] (git+https://github.com/flexxnn/sequelize-auto-migrations.git#0c3b385fffa474b2db825a2b48ce0873a8b9286b)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant