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

Why are numbers stripped from foreign key names #1681

Closed
romainmenke opened this issue Nov 16, 2017 · 1 comment · Fixed by #1728
Closed

Why are numbers stripped from foreign key names #1681

romainmenke opened this issue Nov 16, 2017 · 1 comment · Fixed by #1728
Labels
type:question general questions

Comments

@romainmenke
Copy link

https://github.com/jinzhu/gorm/blob/0a51f6cdc55d1650d9ed3b4c13026cfa9133b01e/dialect_mysql.go#L170

What is the reasoning behind stripping numbers from tables names to generate the foreign key name?

This makes it impossible to create foreign keys for a tables like these :

  • foo_1_model_a
  • foo_1_model_b
  • foo_2_model_a
  • foo_2_model_b

Wordpress MultiSite for example uses this pattern.

@romainmenke
Copy link
Author

I was able to trace this change to this commit :

jinzhu@3a93676#diff-94e8518e61bc1742edb2ac53c97b5daaR611

The commit message states : Port changes made in PR #652

However in #652 there seemingly is no mention or code change related to addForeignKey.

@pedromorgan pedromorgan added the type:question general questions label Dec 13, 2017
iahmedov pushed a commit to housinganywhere/gorm that referenced this issue Sep 3, 2018
blefevre pushed a commit to blefevre/gorm that referenced this issue Feb 17, 2020
blefevre pushed a commit to blefevre/gorm that referenced this issue Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question general questions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants