-
Notifications
You must be signed in to change notification settings - Fork 13
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
Annotated foreign key constraint names not unique #38
Comments
This changes foreign key constraint names to be based on the table and columns of the foreign key, so that they are unique. This is a breaking change.
By the way, this is my second of a series of pull requests. I am submitting them sequentially so that each one can be trivially merged, with no merge conflicts, to minimize the work for the project maintainers. If you prefer that I instead combine fixes for multiple issues in a single pull request, however, please let me know. 😄 Thank you! |
Feel free to submit them all at once, and label them with the order in which we should merge. |
This changes foreign key constraint names to be based on the table and columns of the foreign key, so that they are unique. This is a breaking change.
I created a Thank you! |
A First, the constraint name only takes into account the first column. Though overlapping foreign key constraints are not frequently used, they are valid. In such cases, the constraint names will not be unique, which is a problem. This issue is really easy to fix. Second, the column pairs are created by zipping sorted column names. This works when using Beam naming conventions, but it may be incorrect in cases where custom column names are used. This is not so easy to fix. Personally, I think that matching column order would be better than sorting by column name. This is currently impossible, however, because the order of columns is determined by By the way, I would like to go ahead and implement the fix for the first issue today, and include it in the pull request. The second issue is unrelated to the constraint name and can be considered later. |
This changes the foreign key constraint names created by automatic foreign key discovery to include all constraint columns instead of just the first one, so that they are unique. This is a breaking change.
This changes the foreign key constraint names created by automatic foreign key discovery to include all constraint columns instead of just the first one, so that they are unique. This is a breaking change.
I wrote:
That did not work well, as the new pull request seems to include the commits of the previous pull request (branch) as well. It is my first time to submit interdependent PRs. Please excuse my naïveté. |
When annotating foreign key constraints using
foreignKeyOnPk
orforeignKeyOn
, constraint names are automatically created based on the table and columns of the referenced unique constraint. The name is not necessarily unique because many tables may have foreign key constraints that reference the same unique constraint. The constraint name clashes preventbeam-automigrate
from being able to model non-trivial databases.For example, both
OrderT
andLineItemT
have foreign keys toFlowerT
. TheOrderT
foreign key is annotated with a foreign key constraint. If a foreign key constraint was added for theLineItemT
foreign key, the constraint names would clash.Constraint names should instead be based on the table and columns of the foreign key constraint. This is a breaking change; it changes the names of constraints. I will submit a pull request with the fix.
tc-develop
DocumentationThe text was updated successfully, but these errors were encountered: