In the following I have used attribute/entity instead of field/table.
OK, here is a work-around that I have used today to get groups working on a 1.7>1.8>1,9 upgrade.
You are going to be working with the database. None of this is being done inside moodle. Tyhe work is nothing to do with moodle. It is just
sql. You either need phpmyadmin, webmin, mysqladmin or just enough familiarity with command line to do some fairly basic stuff with mysql. If you work on more than one machine then make sure you are working with the same version of mysql. (Just to play safe).
First of all, If you get the error concerning no password file when doing an upgrade from 1.8>1.9 then change name of the 'enrolmentkey' attribute name in the 'mdl_groups' entity to 'password 'and then try the upgrade again. The 1.9 upgrade script appears to expect the attribute 'password' to be found in mdl_groups in order to change it to 'enrolmentkey'. (I think this may be an issue associated with the upgrade from 1.7>1,8 which many people do not do as 1.7 ended up being a bit of a backwater.).
The new mdl_groups entity has no attribute called courseid. I think this is a problem because a vanilla 1.9 install has the 'courseid' attribute. This leads me to think that an upgraded one should have this as well.
If you just add a courseid attribute to the mdl_groups table then you will not have a good solution because it is an indexed field and it does need to be. If you do not index the attribute then you will suffer performance issues. (Also in the back of my mind I think that with indices it might matter that your courseid is not going to be the second attribute in the entity.).
You are now in the following situation.
1) You have a working upgraded moodle except that your groups are missing (in my case 1.9).
2) You have a backup of your original database from the older moodle where groups did work. (In my case 1.7).
0) Do an sqlbackup of your whole 1.9 database. (Just in case! Really do this. NOT doing this is just silly.).
1) Get the old sql backup of just the original (pre-upgrade database) mdl_groups entity on its own. (In my case version 1.7). Load this original database into mysql as a different database (Don't overwrite your new database!) and then do an sqlbackup of just the mdl_groups entity. Alternatively you can extract the relevant stuff from your whole sql backup of your original database. (You will need a really good text editor to manage this latter technique.)
2) Import just the mdl_groups entity into a new empty database. This is just to do some work.
3) Working in this new database with just the mdl_groups entity. Delete the attributes 'lang' and 'theme'. (If you have a decent text editor then you may be slick enough to do it on the sql backup file but you will have to do some pretty fancy regexp work to kick the attribute values out from the file).
4) Change the type on 'id' and 'courseid' to bigint(10) from int.
5) Do an sqlbackup of the new mdl_groups table which you now have.
6) Execute the sql backup onto your new moodle. In other words, open the 1.9 database that you have in your upgraded moodle and execute the sql backup of the adapted mdl_groups entity on top of it. This will replace your mdl_groups table with your edited version.
7) You can now delete the temporary database(s) you created during this process.
Groups should now work. They did for me. If the whole thing goes belly up then just restore your database from the backup you did at point 0 above.