Repository navigation
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 testornpm run test-DIALECTpass with this change (including linting)?Futurein 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