Skip to content

Commit

Permalink
fix: do not emit m2m relations in WithForeignKeys()
Browse files Browse the repository at this point in the history
Fix for #462
  • Loading branch information
brueli committed Feb 25, 2022
1 parent e6b99ea commit 56c8c5e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions query_table_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ func (q *CreateTableQuery) TableSpace(tablespace string) *CreateTableQuery {

func (q *CreateTableQuery) WithForeignKeys() *CreateTableQuery {
for _, relation := range q.tableModel.Table().Relations {
if relation.Type == schema.ManyToManyRelation {
continue
}
q = q.ForeignKey("(?) REFERENCES ? (?)",
Safe(appendColumns(nil, "", relation.BaseFields)),
relation.JoinTable.SQLName,
Expand Down

0 comments on commit 56c8c5e

Please sign in to comment.