-
Notifications
You must be signed in to change notification settings - Fork 190
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
Add support for multiple outbound foreign keys constraints #77
base: master
Are you sure you want to change the base?
Conversation
7372160
to
3455ed9
Compare
Thanks to #82, the build has passed and this pull request is ready to be merged 😉 |
What is needed to get this PR merged? Can we help on getting it merged? |
Bump, I'd also like to use this, is anything I can do to help get this merged? |
Yes, this is a problem, and we need to fix it. thanks |
3455ed9
to
d1f9004
Compare
I've squashed the commits and rebased the branch. |
@arthurnn how does it look? We've been using @pomier's fork in production at PriceMatch for a while now and haven't run into any issues. Thanks! |
👍 |
Now that we only support ActiveRecord, would be cool to use the FK method they provide https://github.com/rails/rails/blob/4-2-stable/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb#L538-L548 , Only problem is that is only on rails 4.2+ . So maybe we should copy/paste that logic, if we are running on rails 4.2- . WDYT? |
I think we should focus on getting this out instead of continuously commenting / rebasing / refactoring once every six months. It's tested, and it's been working live for months now. It won't be too late to refactor it later to include the relevant rails 4.2 logic if that really stands out as a priority. |
@arthurnn @hannestyden I would be most thankful if you could merge this ? Thanks guys. |
👍 any remaining work here? |
Just ran into this problem today. Thanks for putting in the work to resolve this! |
Any update on this? Would love to see this merged. |
👍 Also running into this problem. Thanks for looking into the fix |
Just got bit by this one too... 👍 |
It's been almost a year since this PR was made. Can we get a maintainer to chime in on what it would take to get this merged in (if at all)? |
d1f9004
to
491d563
Compare
I've rebased this PR from latest master. The tests are now randomly failing the same way it currently happens on master branch. Apart from that, everything is ready to be merged any time now. |
@arthurnn not sure if you are the right guy, but maybe you can point to the right person. What needs to be done to get this merged? It's the only thing preventing me from using this, and right now i have to resort to downtime migrations 😞 |
Kind of frustrating that project maintainers aren't moving at all on this PR. This is incredible work and would really improve the gem. |
I wish this PR was merged. It would solve the problem I have this morning. |
Guys, any updates with this merge? |
@arthurnn are there still changes required before this can be merged, or are you looking for a totally different direction? We'd like to avoid using a fork if at all possible. |
Hey Guys, Can we get this merged and avoid fork? |
@arthurnn We would love to get this in - and are willing to help with this if any changes are needed and help is desired. Can any maintainer let us know whether this is a good direction for the solution, and/or what we can do to help? |
Any chance of getting this merged? It'd really help my project. |
door stuck |
It's 2020!!! |
It's 2021!!! Knock-Knock... |
FWIW, the Shopify fork is more active these days. |
This adds support for tables with multiples outbound foreign keys constraints. This is a modification of pull request #36 who allowed only one foreign key constraint.
The original problem in issue #34 was that lhm tries to create a table with foreign keys constraint having the same name than the original table, producing an error. #36 tried to fix it by modifying the last number at the end of the name.
table_ibfk_1
would then becometable_ibfk_2
.The problem was that the new constraints names were the same when the table had more than one outbound foreign keys, producing the same error than before. Another problem with that solution is that the names produced are not consistent when you undo or redo a migration. The original names are lost forever, so undo a migration won't give you the same structure than before. The new name depends on the original name, so redo a migration may not give the same structure either.
My solution appends a suffix "_lhmn" to the constraint name. If the suffix is already there, we remove it in the new name. If you apply two
change_table
, the constraint names will then be exactly as before. This allows migrations undo and redo to work as they should. Besides, the uniqueness of constraints names is no longer a problem, making lhm support as many outbound foreign key constraints as necessary.