-
Notifications
You must be signed in to change notification settings - Fork 301
Fix multiple fk issue with PostgreSQL migrations #1010
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
Fix multiple fk issue with PostgreSQL migrations #1010
Conversation
| refMap = Map.fromList $ foldl ref [] cols | ||
| where ref rs c = case cReference c of | ||
| Nothing -> rs | ||
| (Just r) -> (unDBName $ cName c, r) : rs |
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.
Here we build a map of column names to foreign keys, so we can pass that on to getColumn.
| ,"AND kcu.table_name=? " | ||
| ,"AND kcu.column_name=?"] | ||
| ,"AND kcu.column_name=? " | ||
| ,"AND tc.constraint_name=?"] |
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.
We now use the reference name to filter the query.
|
Tests seem to be failing for |
|
Looks like newer versions of the |
|
Try merging master - there's an upper bound in place to prevent the cabal solver from picking that version. |
06fceec to
feb00e6
Compare
This commit adds a (failing) test case for when multiple foreign key constraints exist on a single column.
|
@parsonsmatt thanks! |
parsonsmatt
left a comment
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.
Looks great to me. Thanks!
| , T.unpack (unDBName cname) | ||
| , " but got: " | ||
| , show xs | ||
| ] |
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.
❤️ great error message!
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.
That one is all @MaxGabriel
This PR addresses issue #1009 for the PostgreSQL backend. In order to support multiple foreign keys on a single column, we now pass the reference name to
getColumn, and use it in the where clause when querying foreign keys for the column.Before submitting your PR, check that you've:
After submitting your PR: