Okay, the problem was permissions!
The error is confusing because it says
...ALTER command denied to user 'xerteuser'@'localhost' for table...
If I check
that users permissions then they have all permissions.
However, in database.php the host is '127.0.0.1', and for that user ('xerteuser'@'127.0.0.1') the permissions are just select, insert etc. So by allowing the user 'xerteuser' @'127.0.0.1' the ALTER permission, the script then works fine in adding the new field.
I guess when I added the field manually from the command line it was because I was seen as being from 'localhost'.
Anyway, problem solved. Many thanks for your help.