diff --git a/go/logic/inspect.go b/go/logic/inspect.go index 3ece8ab26..83748cb56 100644 --- a/go/logic/inspect.go +++ b/go/logic/inspect.go @@ -445,11 +445,10 @@ func (this *Inspector) validateTableForeignKeys(allowChildForeignKeys bool) erro SUM(REFERENCED_TABLE_NAME IS NOT NULL AND TABLE_SCHEMA=? AND TABLE_NAME=?) as num_child_side_fk, SUM(REFERENCED_TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_SCHEMA=? AND REFERENCED_TABLE_NAME=?) as num_parent_side_fk FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE - WHERE - REFERENCED_TABLE_NAME IS NOT NULL - AND ((TABLE_SCHEMA=? AND TABLE_NAME=?) - OR (REFERENCED_TABLE_SCHEMA=? AND REFERENCED_TABLE_NAME=?) - ) + WHERE REFERENCED_TABLE_NAME IS NOT NULL + AND ORDINAL_POSITION = 1 + AND ((TABLE_SCHEMA=? AND TABLE_NAME=?) + OR (REFERENCED_TABLE_SCHEMA=? AND REFERENCED_TABLE_NAME=?)) ` numParentForeignKeys := 0 numChildForeignKeys := 0