This fixes the issue that the upgrade seems to work but the change from permissions.user to permissions.userid is not applied because of the foreign key.
Renamed the user table to users and added a unique key to it so
duplicate users can't be created.
Upgrade scripts delete duplicates and keep the lowest id (which is what
would have been used for authentication anyway, i.e. other users were
useless).
Added upgrade script to put domains names and records names to lower
case text as is required by postgres.