code: func CreateGatewayProfile(db sqlx.Execer, c *GatewayProfile) error {
  	now := time.Now()
  	c.CreatedAt = now
  	c.UpdatedAt = now
  
  	if c.ID == uuid.Nil {
  		var err error
  		c.ID, err = uuid.NewV4()
  		if err != nil {
  			return errors.Wrap(err, "new uuid v4 error")
  		}
  	}
  
  	_, err := db.Exec(`
  		insert into gateway_profile (
  			gateway_profile_id,
  			created_at,
  			updated_at,
  			channels
  		) values ($1, $2, $3, $4)`,
  		c.ID,
  		c.CreatedAt,
  		c.UpdatedAt,
  		pq.Array(c.Channels),
  	)
  	if err != nil {
  		return handlePSQLError(err, "insert error")
  	}
  
  	for _, ec := range c.ExtraChannels {
  		_, err := db.Exec(`
  			insert into gateway_profile_extra_channel (
  				gateway_profile_id,
  				modulation,
  				frequency,
  				bandwidth,
  				bitrate,
  				spreading_factors
  			) values ($1, $2, $3, $4, $5, $6)`,
  			c.ID,
  			ec.Modulation,
  			ec.Frequency,
  			ec.Bandwidth,
  			ec.Bitrate,
  			pq.Array(ec.SpreadingFactors),
  		)
  		if err != nil {
  			return handlePSQLError(err, "insert error")
  		}
  	}
  
  	log.WithFields(log.Fields{
  		"id": c.ID,
  	}).Info("gateway-profile created")
  
  	return nil
  }
docs: // CreateGatewayProfile creates the given gateway-profile.
  // As this will execute multiple SQL statements, it is recommended to perform
  // this within a transaction.