-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
Issue type:
[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[x] @next
[ ] 0.x.x (or put your version here)
Steps to reproduce or a small repository showing the problem:
It appears that migrations do not generate up and down statements to modify a foreign key when the referenced table changes. This maybe be a dup of #3509, but I have a reproduction repo and believe I found the root cause and potential solution.
After digging for a solution, I found that DefaultNamingStrategy does not incorporate the referenced table name when generating a foreign key name, despite it being a parameter to the method.
Off the top of my head, I see two solutions so far:
- Update the naming strategy to incorporate the referenced table name. However, this would cause a lot of noise for all users since all foreign keys would be renamed.
- Update
RdbmsSchemaBuilder.dropOldForeignKeys()andRdbmsSchemaBuilder.createForeignKeys()to check for the change in referenced table name and generate a new FK with the same name.
Any other thoughts on how to fix this?