cubicweb/server/migractions.py
changeset 12742 ca698656251c
parent 12567 26744ad37953
child 12745 cc681b6fcffa
equal deleted inserted replaced
12741:90348f847b4b 12742:ca698656251c
  1388         indexable entity types
  1388         indexable entity types
  1389         """
  1389         """
  1390         from cubicweb.server.checkintegrity import reindex_entities
  1390         from cubicweb.server.checkintegrity import reindex_entities
  1391         reindex_entities(self.repo.schema, self.cnx, etypes=etypes)
  1391         reindex_entities(self.repo.schema, self.cnx, etypes=etypes)
  1392 
  1392 
       
  1393     def cmd_update_bfss_path(self, old_path, new_path, commit=True):
       
  1394         """
       
  1395         Change the path of all Files from old_path to new_path.
       
  1396         """
       
  1397         changes = []
       
  1398         for f_eid, fspath in self.rqlexec(
       
  1399                 'Any F, FSPATH(D) WHERE F is File, F data D'):
       
  1400             fspath = fspath.getvalue().decode('utf-8')
       
  1401             dirname = os.path.dirname(fspath)
       
  1402             if dirname == old_path:
       
  1403                 newpath = os.path.join(new_path, os.path.basename(fspath))
       
  1404                 changes.append({'expected': newpath, 'eid': f_eid})
       
  1405         self.repo.system_source.doexecmany(
       
  1406             self.cnx,
       
  1407             'UPDATE cw_file SET cw_data=%(expected)s WHERE cw_eid=%(eid)s',
       
  1408             changes)
       
  1409         if commit:
       
  1410             self.commit()
       
  1411 
  1393     @contextmanager
  1412     @contextmanager
  1394     def cmd_dropped_constraints(self, etype, attrname, cstrtype=None,
  1413     def cmd_dropped_constraints(self, etype, attrname, cstrtype=None,
  1395                                 droprequired=False):
  1414                                 droprequired=False):
  1396         """context manager to drop constraints temporarily on fs_schema
  1415         """context manager to drop constraints temporarily on fs_schema
  1397 
  1416