From 96ed3413fc443ab3a8636696a48b34f51d5deb8b Mon Sep 17 00:00:00 2001 From: Pestdoktor Date: Fri, 13 Dec 2019 05:40:17 +0100 Subject: [PATCH] one-to-many-through: use correct fkey (#27) --- psql/schema.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/psql/schema.go b/psql/schema.go index acaf81a..0d697aa 100644 --- a/psql/schema.go +++ b/psql/schema.go @@ -209,12 +209,12 @@ func (s *DBSchema) updateSchemaOTMT( t1 := strings.ToLower(col1.FKeyTable) t2 := strings.ToLower(col2.FKeyTable) - fc1, ok := ti.ColIDMap[col1.FKeyColID[0]] + fc1, ok := s.t[t1].ColIDMap[col1.FKeyColID[0]] if !ok { return fmt.Errorf("invalid foreign key column id '%d' for table '%s'", col1.FKeyColID[0], ti.Name) } - fc2, ok := ti.ColIDMap[col2.FKeyColID[0]] + fc2, ok := s.t[t2].ColIDMap[col2.FKeyColID[0]] if !ok { return fmt.Errorf("invalid foreign key column id '%d' for table '%s'", col2.FKeyColID[0], ti.Name)