You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: configurator.go
    path of file: ./repos/magma/orc8r/cloud/go/tools/migrations
    
    the code of the file until where you have to start completion: /*
 Copyright 2020 The Magma Authors.

 This source code is licensed under the BSD-style license found in the
 LICENSE file in the root directory of this source tree.

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/

package migrations

import (
	"crypto/md5"
	"fmt"

	"github.com/Masterminds/squirrel"
	"github.com/golang/glog"
	"github.com/google/uuid"
)

// Duplicated from configurator
const (
	entityTable      = "cfg_entities"
	entityAssocTable = "cfg_assocs"

	entPkCol   = "pk"
	entTypeCol = "type"

	aFrCol = "from_pk"
	aToCol = "to_pk"
)

// AssocDirection is the desired direction of the assoc edge between two types
type AssocDirection struct {
	FromType string
	ToType   string
}

type assocPair struct {
	fromPk string
	toPk   string
}

func MakePK() string {
	return uuid.New().String()
}

// MakeDeterministicPK returns a PK in the expected UUID format, but created
// deterministically from the (network, type, key) p
    
func SetAssocDirections(builder squirrel.StatementBuilderType, edges []AssocDirection) error {
	/*
		SELECT from_pk,to_pk
		FROM cfg_entities AS a
		JOIN cfg_assocs ON a.pk=from_pk
		JOIN cfg_entities AS b ON to_pk=b.pk
		WHERE
			(a.type='edge0.FromType' AND b.type='edge0.ToType') OR
			(a.type='edge1.FromType' AND b.type='edge1.ToType') OR
			...
	*/

	tblA, tblB := "a", "b"
	pkColA, pkColB := makeCol(tblA, entPkCol), makeCol(tblB, entPkCol)
	typeColA, typeColB := makeCol(tblA, entTypeCol), makeCol(tblB, entTypeCol)

	var where squirrel.Or
	for _, assoc := range edges {
		where = append(where, squirrel.Eq{typeColA: assoc.ToType, typeColB: assoc.FromType})
	}

	rows, err := builder.
		Select(aFrCol, aToCol).
		From(fmt.Sprintf("%s AS %s", entityTable, tblA)).
		Join(fmt.Sprintf("%s ON %s=%s", entityAssocTable, pkColA, aFrCol)).
		Join(fmt.Sprintf("%s AS %s ON %s=%s", entityTable, tblB, aToCol, pkColB)).
		Where(where).
		Query()
	if err != nil {
		return fmt.Errorf("get existing assocs to flip: %w", err)
	}

	var assocs []assocPair
	for rows.Next() {
		assoc := assocPair{}
		err = rows.Scan(&assoc.fromPk, &assoc.toPk)
		if err != nil {
			return fmt.Errorf("scan assocs: %w", err)
		}
		assocs = append(assocs, assoc)
	}
	err = rows.Err()
	if err != nil {
		return fmt.Errorf("get existing assocs: SQL rows error: %w", err)
	}

	glog.Infof("Flipping %d assocs", len(assocs))
	for _, assoc := range assocs {
		err := flipAssocDirection(builder, assoc)
		if err != nil {
			return err
		}
	}

	return nil
}