server/migractions.py
changeset 5397 cdbf823450aa
parent 5302 dfd147de06b2
child 5408 120db445c179
--- a/server/migractions.py	Fri Apr 23 17:54:34 2010 +0200
+++ b/server/migractions.py	Fri Apr 23 17:55:46 2010 +0200
@@ -1179,6 +1179,23 @@
             return session
         return self.cnx.request()
 
+    def cmd_storage_changed(self, etype, attribute):
+        """migrate entities to a custom storage. The new storage is expected to
+        be set, it will be temporarily removed for the migration.
+        """
+        from logilab.common.shellutils import ProgressBar
+        source = self.repo.system_source
+        storage = source.storage(etype, attribute)
+        source.unset_storage(etype, attribute)
+        rset = self.rqlexec('Any X,A WHERE X is %s, X %s A'
+                            % (etype, attribute), ask_confirm=False)
+        pb = ProgressBar(len(rset))
+        for entity in rset.entities():
+            storage.migrate_entity(entity, attribute)
+            pb.update()
+        print
+        source.set_storage(etype, attribute, storage)
+
     def cmd_create_entity(self, etype, commit=False, **kwargs):
         """add a new entity of the given type"""
         entity = self._cw.create_entity(etype, **kwargs)