[migration] when adding a core meta-relation, it should be added to all entities *in the persistent schema*, not only those in the fs schema
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 05 Aug 2009 17:27:33 +0200
changeset 2700 ecf888c8a250
parent 2699 1025300249d2
child 2704 09516a696636
[migration] when adding a core meta-relation, it should be added to all entities *in the persistent schema*, not only those in the fs schema
server/migractions.py
--- a/server/migractions.py	Wed Aug 05 17:26:41 2009 +0200
+++ b/server/migractions.py	Wed Aug 05 17:27:33 2009 +0200
@@ -694,6 +694,22 @@
             self.commit()
             self.rqlexecall(ss.rdef2rql(rschema),
                             ask_confirm=self.verbosity>=2)
+            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
+                # the fs schema
+                for etype in self.repo.schema.entities():
+                    if not etype in self.fs_schema:
+                        # get sample object type and rproperties
+                        objtypes = rschema.objects()
+                        assert len(objtypes) == 1
+                        objtype = objtypes[0]
+                        props = rschema.rproperties(
+                            rschema.subjects(objtype)[0], objtype)
+                        assert props
+                        self.rqlexecall(ss.rdef2rql(rschema, etype, objtype, props),
+                                        ask_confirm=self.verbosity>=2)
+
         if commit:
             self.commit()