lxd/db/migration.go
func importNodeAssociation(entity string, columns []string, row []interface{}, tx *sql.Tx) error {
	stmt := fmt.Sprintf(
		"INSERT INTO %ss_nodes(%s_id, node_id) VALUES(?, 1)", entity, entity)
	var id int64
	for i, column := range columns {
		if column == "id" {
			id = row[i].(int64)
			break
		}
	}
	if id == 0 {
		return fmt.Errorf("entity %s has invalid ID", entity)
	}
	_, err := tx.Exec(stmt, id)
	if err != nil {
		return errors.Wrapf(err, "failed to associate %s to node", entity)
	}
	return nil
}
func importNodeAssociation(entity string, columns []string, row []interface{}, tx *sql.Tx) error {
	stmt := fmt.Sprintf(
		"INSERT INTO %ss_nodes(%s_id, node_id) VALUES(?, 1)", entity, entity)
	var id int64
	for i, column := range columns {
		if column == "id" {
			id = row[i].(int64)
			break
		}
	}
	if id == 0 {
		return fmt.Errorf("entity %s has invalid ID", entity)
	}
	_, err := tx.Exec(stmt, id)
	if err != nil {
		return errors.Wrapf(err, "failed to associate %s to node", entity)
	}
	return nil
}
// Insert a row in one of the nodes association tables (storage_pools_nodes,
// networks_nodes, images_nodes).