diff --git a/dialects/postgres.go b/dialects/postgres.go index 0ff7d875..5fdaeeba 100644 --- a/dialects/postgres.go +++ b/dialects/postgres.go @@ -981,17 +981,17 @@ func (db *postgres) CreateTableSQL(table *schemas.Table, tableName string) ([]st s, _ := ColumnString(db, col, col.IsPrimaryKey && len(table.PrimaryKeys) == 1) b.WriteString(s) - if len(table.PrimaryKeys) > 1 { - b.WriteString("PRIMARY KEY ( ") - b.WriteString(quoter.Join(table.PrimaryKeys, ",")) - b.WriteString(" )") - } - if i != len(table.ColumnsSeq())-1 { b.WriteString(", ") } } + if len(table.PrimaryKeys) > 1 { + b.WriteString(", PRIMARY KEY (") + b.WriteString(quoter.Join(table.PrimaryKeys, ",")) + b.WriteString(")") + } + b.WriteString(")") return []string{b.String()}, false