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

mysql error on content-type change: ER_FK_DUP_NAME: Duplicate FOREIGN KEY constraint name #20283

Open
jarnix opened this issue May 8, 2024 · 0 comments
Assignees
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:database Source is core/database package status: pending reproduction Waiting for free time to reproduce the issue, or more information

Comments

@jarnix
Copy link

jarnix commented May 8, 2024

Bug report

Required System information

  • Node.js version: 20.13.0
  • NPM version: 10.5.2
  • Strapi version: 4.24.2
  • Database: mysql
  • Operating system: linux
  • Is your project Javascript or Typescript: Javascript

Describe the bug

 Error: ER_FK_DUP_NAME: Duplicate FOREIGN KEY constraint name 'blog/admin_permissions_created_by_id_fk'                │
│       at Sequence._packetToError (/home/julien/web/blog3/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)   │
│       at Query.ErrorPacket (/home/julien/web/blog3/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)            │
│       at Protocol._parsePacket (/home/julien/web/blog3/node_modules/mysql/lib/protocol/Protocol.js:291:23)              │
│       at Parser._parsePacket (/home/julien/web/blog3/node_modules/mysql/lib/protocol/Parser.js:433:10)                  │
│       at Parser.write (/home/julien/web/blog3/node_modules/mysql/lib/protocol/Parser.js:43:10)                          │
│       at Protocol.write (/home/julien/web/blog3/node_modules/mysql/lib/protocol/Protocol.js:38:16)                      │
│       at Socket.<anonymous> (/home/julien/web/blog3/node_modules/mysql/lib/Connection.js:88:28)                         │
│       at Socket.<anonymous> (/home/julien/web/blog3/node_modules/mysql/lib/Connection.js:526:10)                        │
│       at Socket.emit (node:events:519:28)                                                                               │
│       at Socket.emit (node:domain:488:12)                                                                               │
│       --------------------                                                                                              │
│       at Protocol._enqueue (/home/julien/web/blog3/node_modules/mysql/lib/protocol/Protocol.js:144:48)                  │
│       at Connection.query (/home/julien/web/blog3/node_modules/mysql/lib/Connection.js:198:25)                          │
│       at /home/julien/web/blog3/node_modules/knex/lib/dialects/mysql/index.js:132:18                                    │
│       at new Promise (<anonymous>)                                                                                      │
│       at Client_MySQL._query (/home/julien/web/blog3/node_modules/knex/lib/dialects/mysql/index.js:126:12)              │
│       at executeQuery (/home/julien/web/blog3/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)      │
│       at Client_MySQL.query (/home/julien/web/blog3/node_modules/knex/lib/client.js:154:12)                             │
│       at /home/julien/web/blog3/node_modules/knex/lib/execution/transaction.js:371:24                                   │
│       at new Promise (<anonymous>)                                                                                      │
│       at trxClient.query (/home/julien/web/blog3/node_modules/knex/lib/execution/transaction.js:366:12)                 │
│

There is no way of going further. I have to delete every table and restart but I will lose every content of course.

Steps to reproduce the behavior

First launch, after creating the first user, going to the content-type builder, I added one field, and then clicked on Save. Strapi restarts with this error:

Expected behavior

The server should restart properly and not try to create duplicated foreign keys.

Additional context

This happens with mysql, not with a file db, there is no fk in the file db...

@jarnix jarnix changed the title ER_FK_DUP_NAME: Duplicate FOREIGN KEY constraint name on content-type change mysql error on content-type change: ER_FK_DUP_NAME: Duplicate FOREIGN KEY constraint name May 8, 2024
@joshuaellis joshuaellis added issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:database Source is core/database package status: pending reproduction Waiting for free time to reproduce the issue, or more information labels May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:database Source is core/database package status: pending reproduction Waiting for free time to reproduce the issue, or more information
Projects
Status: To be reviewed (Open)
Status: To review
Development

No branches or pull requests

3 participants