code: func CreateDevice(db sqlx.Execer, d *Device) error {
  	now := time.Now()
  	d.CreatedAt = now
  	d.UpdatedAt = now
  
  	_, err := db.Exec(`
  		insert into device (
  			dev_eui,
  			created_at,
  			updated_at,
  			device_profile_id,
  			service_profile_id,
  			routing_profile_id,
  			skip_fcnt_check,
  			reference_altitude,
  			mode
  		) values ($1, $2, $3, $4, $5, $6, $7, $8, $9)`,
  		d.DevEUI[:],
  		d.CreatedAt,
  		d.UpdatedAt,
  		d.DeviceProfileID,
  		d.ServiceProfileID,
  		d.RoutingProfileID,
  		d.SkipFCntCheck,
  		d.ReferenceAltitude,
  		d.Mode,
  	)
  	if err != nil {
  		return handlePSQLError(err, "insert error")
  	}
  
  	log.WithFields(log.Fields{
  		"dev_eui": d.DevEUI,
  	}).Info("device created")
  
  	return nil
  }
docs: // CreateDevice creates the given device.