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
Drop only existing foreign_keys #240
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK this patch fixed the issue
| remove_foreign_key 'host_classes', 'puppetclasses', name: 'host_classes_puppetclass_id_fk' | ||
| remove_foreign_key 'operatingsystems_puppetclasses', 'operatingsystems', name: 'operatingsystems_puppetclasses_operatingsystem_id_fk' | ||
| remove_foreign_key 'operatingsystems_puppetclasses', 'puppetclasses', name: 'operatingsystems_puppetclasses_puppetclass_id_fk' | ||
| remove_foreign_key('host_classes', 'hosts') if foreign_key_exists?(:host_classes, :hosts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea whether this error can occur for the other migrations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no idea if it can, it didn't in Satellite usecase, but I can add the condition to all of them :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't hurt I guess :) Any idea why the error occurred in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it was because of the FK was created with the table alrady and thus had a default name, not the name given by us.
|
Could you please add a more descriptive commit message :) |
Some foreign keys have been already created with other names or not created at all. This adds a security measure to remove the key whatever the name is if it exists. Fixes theforeman#239
f791111
to
c95fd46
Compare
|
Better? :) |
|
LGTM! Thanks @ezr-ondrej |
|
CP 2.0: 6b5f43a |
Fixes #239