[migration] fix add_relation_type in case it already exists, broken by 67660d5f1916 stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 01 Mar 2012 13:39:43 +0100
branchstable
changeset 8285 32098d98bf2f
parent 8284 bca3e67fdba9
child 8286 8b0146e31baa
[migration] fix add_relation_type in case it already exists, broken by 67660d5f1916
server/migractions.py
--- a/server/migractions.py	Thu Mar 01 08:55:14 2012 +0100
+++ b/server/migractions.py	Thu Mar 01 13:39:43 2012 +0100
@@ -1036,17 +1036,15 @@
             gmap = self.group_mapping()
             cmap = self.cstrtype_mapping()
             done = set()
-            for rdef in rschema.rdefs.itervalues():
-                if not (reposchema.has_entity(rdef.subject)
-                        and reposchema.has_entity(rdef.object)):
+            for subj, obj in rschema.rdefs:
+                if not (reposchema.has_entity(subj)
+                        and reposchema.has_entity(obj)):
                     continue
                 # symmetric relations appears twice
-                if (rdef.subject, rdef.object) in done:
+                if (subj, obj) in done:
                     continue
-                done.add( (rdef.subject, rdef.object) )
-                self._set_rdef_eid(rdef)
-                ss.execschemarql(execute, rdef,
-                                 ss.rdef2rql(rdef, cmap, gmap))
+                done.add( (subj, obj) )
+                self.cmd_add_relation_definition(subj, rtype, obj)
             if rtype in META_RTYPES:
                 # if the relation is in META_RTYPES, ensure we're adding it for
                 # all entity types *in the persistent schema*, not only those in
@@ -1096,9 +1094,8 @@
             print 'warning: relation %s %s %s is already known, skip addition' % (
                 subjtype, rtype, objtype)
             return
-        execute = self._cw.execute
         rdef = self._get_rdef(rschema, subjtype, objtype)
-        ss.execschemarql(execute, rdef,
+        ss.execschemarql(self._cw.execute, rdef,
                          ss.rdef2rql(rdef, self.cstrtype_mapping(),
                                      self.group_mapping()))
         if commit: