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
Include tableName in MySQL fk contraint names #6008
Conversation
When creating a foreign key constraint in MySQL, use the template {referring_table}_{attribute}_foreign_idx, rather than just {attribute}_foreign_idx, to avoid duplicate constraint names. Related tests are updated. See GitHub sequelize#5826
LGTM, /cc @janmeier |
any chance this could be released? |
@danielepolencic This PR targeted master so it's slated for the next 4.0 pre release. |
@mickhansen any chance of backporting this to 3.x? As it is impossible to set the name of the constraint, only raw SQL is left for the rescue. |
Isnt this a beaking change? |
@felixfbecker I don't believe so since we don't really depend on constraint names anywhere. |
@mickhansen we don't, but a user might (think raw queries in migration files, etc). It's like changing the default casing of table names. |
@felixfbecker That is true |
@eliias it will land in v4 |
It is really sad that we have to wait until v4 for this. In the meantime, as a workaround, I'm setting the column to be something like If you find a nicer workaround please share it! |
Fix for MySQL fk constraint names Cherry-picked from 85477dd See also issue sequelize#5826
Fix for MySQL fk constraint names to incorporate referring table name and avoid possible name collisions. Cherry-picked from 85477dd See also issue sequelize#5826
Fix for MySQL fk constraint names to incorporate referring table name and avoid possible name collisions. Cherry-picked from 85477dd See also issue sequelize#5826
Thank you for breaking changes! |
Fix for MySQL fk constraint names to incorporate referring table name and avoid possible name collisions. Cherry-picked from 85477dd See also issue sequelize#5826
This problem also affects mssql dialect. Any plans to change it there? |
Pull Request check-list
npm run test
ornpm run test-DIALECT
pass with this change (including linting)?Future
in the changelog?Description of change
When creating a foreign key constraint in MySQL, use the template
{referring_table}_{attribute}_foreign_idx
, rather than just{attribute}_foreign_idx
, to avoid duplicate constraint names.See GitHub #5826