[schema deserial] fix loading of schema when mapping an entity type to an existing one
To ensure rdef of the old entity type don't overwrite those already existing
on the mapped entity type.
Also rename some variables/arguments on the way to make things clearer.
frombase64importb64decode,b64encodetry:uri,newdn=__args__exceptValueError:print'USAGE: cubicweb-ctl shell <instance> ldap_change_base_dn.py -- <ldap source uri> <new dn>'printprint'you should not have updated your sources file yet'olddn=repo.config.sources()[uri]['user-base-dn']assertolddn!=newdnraw_input("Ensure you've stopped the instance, type enter when done.")foreid,extidinsql("SELECT eid, extid FROM entities WHERE source='%s'"%uri):olduserdn=b64decode(extid)newuserdn=olduserdn.replace(olddn,newdn)ifnewuserdn!=olduserdn:printolduserdn,'->',newuserdnsql("UPDATE entities SET extid='%s' WHERE eid=%s"%(b64encode(newuserdn),eid))commit()print'you can now update the sources file to the new dn and restart the instance'