The current implementation of constraintIdentifier for foreign key prefixed all local and foreign fields with the local table name, but the output is not unique in fact.
Both constraint has the identifier fk:a.id+a.id, so the creation would fail.
Expected behavior
For the example above, the identifiers should be:
fk:a.id+b.id
fk:a.id+c.id
Additional context
Fixing the implementation is easy, but this affects all existing foreign keys without explicit naming, and users cannot delete them by deleteConstraint(_ constraint: DatabaseSchema.ConstraintDelete), so it is breaking and should be noticed in the upgrading guide.
Describe the bug
The current implementation of
constraintIdentifier
for foreign key prefixed all local and foreign fields with the local table name, but the output is not unique in fact.To Reproduce
Both constraint has the identifier
fk:a.id+a.id
, so the creation would fail.Expected behavior
For the example above, the identifiers should be:
fk:a.id+b.id
fk:a.id+c.id
Additional context
Fixing the implementation is easy, but this affects all existing foreign keys without explicit naming, and users cannot delete them by
deleteConstraint(_ constraint: DatabaseSchema.ConstraintDelete)
, so it is breaking and should be noticed in the upgrading guide.