When annotating foreign key constraints using foreignKeyOnPk or foreignKeyOn, 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 prevent beam-automigrate from being able to model non-trivial databases.
For example, both OrderT and LineItemT have foreign keys to FlowerT. The OrderT foreign key is annotated with a foreign key constraint. If a foreign key constraint was added for the LineItemT 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 Documentation
When annotating foreign key constraints using
foreignKeyOnPkorforeignKeyOn, 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-automigratefrom being able to model non-trivial databases.For example, both
OrderTandLineItemThave foreign keys toFlowerT. TheOrderTforeign key is annotated with a foreign key constraint. If a foreign key constraint was added for theLineItemTforeign 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-developDocumentation