1198 """ |
1198 """ |
1199 from logilab.common.shellutils import ProgressBar |
1199 from logilab.common.shellutils import ProgressBar |
1200 source = self.repo.system_source |
1200 source = self.repo.system_source |
1201 storage = source.storage(etype, attribute) |
1201 storage = source.storage(etype, attribute) |
1202 source.unset_storage(etype, attribute) |
1202 source.unset_storage(etype, attribute) |
1203 rset = self.rqlexec('Any X,A WHERE X is %s, X %s A' |
1203 rset = self.rqlexec('Any X WHERE X is %s' etype, ask_confirm=False) |
1204 % (etype, attribute), ask_confirm=False) |
|
1205 pb = ProgressBar(len(rset)) |
1204 pb = ProgressBar(len(rset)) |
1206 for entity in rset.entities(): |
1205 for entity in rset.entities(): |
|
1206 # fill cache. Do not fetch that attribute using the global rql query |
|
1207 # since we may exhaust memory doing that.... |
|
1208 getattr(entity, attribute) |
1207 storage.migrate_entity(entity, attribute) |
1209 storage.migrate_entity(entity, attribute) |
|
1210 # remove from entity cache to avoid memory exhaustion |
|
1211 del entity[attribute] |
1208 pb.update() |
1212 pb.update() |
1209 print |
1213 print |
1210 source.set_storage(etype, attribute, storage) |
1214 source.set_storage(etype, attribute, storage) |
1211 |
1215 |
1212 def cmd_create_entity(self, etype, commit=False, **kwargs): |
1216 def cmd_create_entity(self, etype, commit=False, **kwargs): |