You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Models with cyclic foreign keys and ENUM-typed fields can't be synced in Postgres #15522
In PostgreSQL, when there is a circular dependency between models (following foreign keys) and at least some model in the database has an ENUM-typed property, calls to sequelize.sync() will fail, as the enum type is attempted to be created twice.
This bug seems to have been introduced in v6.20.0, when support for cyclic foreign keys was added. The implementation synchronizes the models twice, first to create the tables, and then to create the foreign keys. Both runs are attempting to create the types for the ENUM-typed fields, which is not an idempotent operation.
No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in resolving my issue.
Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.
Activity
WikiRik commentedon Jan 3, 2023
I can confirm this on
mainas well, by copying the following test and adding the enum to there;sequelize/test/integration/model/sync.test.js
Lines 527 to 555 in 989713a
I think part of the fix should be in
changeColumnso I'll tag @ephys in here.ephys commentedon Jan 4, 2023
This is a variant of #7649. The cause is the same, but we can add this test to the new suite to make sure