[migration] handle the case where new final entity type is not yet in the schema
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 09 Dec 2015 17:44:17 +0100
changeset 11001 37c5c9b3b3bf
parent 11000 dc9de651c328
child 11002 2973522a1924
[migration] handle the case where new final entity type is not yet in the schema This may occur on new cube addition. Related to #7569998.
server/migractions.py
--- a/server/migractions.py	Wed Dec 09 17:44:16 2015 +0100
+++ b/server/migractions.py	Wed Dec 09 17:44:17 2015 +0100
@@ -47,6 +47,7 @@
 from logilab.common.deprecation import deprecated
 from logilab.common.decorators import cached, clear_cache
 
+from yams.buildobjs import EntityType
 from yams.constraints import SizeConstraint
 from yams.schema import RelationDefinitionSchema
 
@@ -790,6 +791,11 @@
         cstrtypemap = self.cstrtype_mapping()
         # register the entity into CWEType
         execute = self.cnx.execute
+        if eschema.final and eschema not in instschema:
+            # final types are expected to be in the living schema by default, but they are not if
+            # the type is defined in a cube that is being added
+            edef = EntityType(eschema.type, __permissions__=eschema.permissions)
+            instschema.add_entity_type(edef)
         ss.execschemarql(execute, eschema, ss.eschema2rql(eschema, groupmap))
         # add specializes relation if needed
         specialized = eschema.specializes()