Issue #831134 by MegaChriz: fixed bug in upgrade script. Upgrading resulted in failures when long field names (> 11 characters) where used.