This commit is contained in:
Adria Navarro 2024-04-19 12:39:04 +02:00
parent 1685568089
commit 72c65cd7fd
1 changed files with 4 additions and 1 deletions

View File

@ -40,8 +40,11 @@ function checkForeignKeysAreAutoColumns(datasource: Datasource) {
const shouldBeForeign = foreignKeys.find( const shouldBeForeign = foreignKeys.find(
options => options.tableId === table._id && options.key === column.name options => options.tableId === table._id && options.key === column.name
) )
if (column.autocolumn) {
continue
}
// don't change already auto-columns to it, e.g. primary keys that are foreign // don't change already auto-columns to it, e.g. primary keys that are foreign
if (shouldBeForeign && !column.autocolumn) { if (shouldBeForeign) {
column.autocolumn = true column.autocolumn = true
column.autoReason = AutoReason.FOREIGN_KEY column.autoReason = AutoReason.FOREIGN_KEY
} else if (column.autoReason === AutoReason.FOREIGN_KEY) { } else if (column.autoReason === AutoReason.FOREIGN_KEY) {