[migraction] rename_entity_type simply warn if old entity type isn't in the schema. Closes #3004069
--- a/server/migractions.py Thu Jul 11 10:15:25 2013 +0200
+++ b/server/migractions.py Thu Jul 11 10:20:42 2013 +0200
@@ -1,4 +1,4 @@
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
@@ -929,6 +929,10 @@
`newname` is a string giving the name of the renamed entity type
"""
schema = self.repo.schema
+ if oldname not in schema:
+ print 'warning: entity type %s is unknown, skip renaming' % oldname
+ return
+ # if merging two existing entity types
if newname in schema:
assert oldname in ETYPE_NAME_MAP, \
'%s should be mapped to %s in ETYPE_NAME_MAP' % (oldname,
@@ -1003,6 +1007,7 @@
# remove the old type: use rql to propagate deletion
self.rqlexec('DELETE CWEType ET WHERE ET name %(on)s', {'on': oldname},
ask_confirm=False)
+ # elif simply renaming an entity type
else:
self.rqlexec('SET ET name %(newname)s WHERE ET is CWEType, ET name %(on)s',
{'newname' : unicode(newname), 'on' : oldname},