hooks/syncschema.py
branchstable
changeset 5845 4e28f03651d4
parent 5834 b8ad49864928
child 5846 0337e6870de4
equal deleted inserted replaced
5844:df7608ecea29 5845:4e28f03651d4
   249         rschema = self.rschema
   249         rschema = self.rschema
   250         if rschema.final:
   250         if rschema.final:
   251             return
   251             return
   252         session = self.session
   252         session = self.session
   253         if 'fulltext_container' in self.values:
   253         if 'fulltext_container' in self.values:
   254             ftiupdates = session.transaction_data.setdefault(
       
   255                 'fti_update_etypes', set())
       
   256             for subjtype, objtype in rschema.rdefs:
   254             for subjtype, objtype in rschema.rdefs:
   257                 ftiupdates.add(subjtype)
   255                 hook.set_operation(self._cw, 'fti_update_etypes', subjtype,
   258                 ftiupdates.add(objtype)
   256                                    UpdateFTIndexOp)
   259             UpdateFTIndexOp(session)
   257                 hook.set_operation(self._cw, 'fti_update_etypes', objtype,
       
   258                                    UpdateFTIndexOp)
   260         if not 'inlined' in self.values:
   259         if not 'inlined' in self.values:
   261             return # nothing to do
   260             return # nothing to do
   262         inlined = self.values['inlined']
   261         inlined = self.values['inlined']
   263         # check in-lining is necessary / possible
   262         # check in-lining is necessary / possible
   264         if inlined:
   263         if inlined:
   521                                                 self.session.system_sql)
   520                                                 self.session.system_sql)
   522             else:
   521             else:
   523                 sql = adbh.sql_set_null_allowed(table, column, coltype, notnull)
   522                 sql = adbh.sql_set_null_allowed(table, column, coltype, notnull)
   524             session.system_sql(sql)
   523             session.system_sql(sql)
   525         if 'fulltextindexed' in self.values:
   524         if 'fulltextindexed' in self.values:
   526             UpdateFTIndexOp(session)
   525             hook.set_operation(self._cw, 'fti_update_etypes', etype,
   527             session.transaction_data.setdefault(
   526                                UpdateFTIndexOp)
   528                 'fti_update_etypes', set()).add(etype)
       
   529 
   527 
   530 
   528 
   531 class SourceDbCWConstraintAdd(hook.Operation):
   529 class SourceDbCWConstraintAdd(hook.Operation):
   532     """actually update constraint of a relation definition"""
   530     """actually update constraint of a relation definition"""
   533     entity = None # make pylint happy
   531     entity = None # make pylint happy
  1182     """
  1180     """
  1183 
  1181 
  1184     def postcommit_event(self):
  1182     def postcommit_event(self):
  1185         session = self.session
  1183         session = self.session
  1186         source = session.repo.system_source
  1184         source = session.repo.system_source
  1187         to_reindex = session.transaction_data.get('fti_update_etypes', ())
  1185         to_reindex = session.transaction_data.pop('fti_update_etypes', ())
  1188         self.info('%i etypes need full text indexed reindexation',
  1186         self.info('%i etypes need full text indexed reindexation',
  1189                   len(to_reindex))
  1187                   len(to_reindex))
  1190         schema = self.session.repo.vreg.schema
  1188         schema = self.session.repo.vreg.schema
  1191         for etype in to_reindex:
  1189         for etype in to_reindex:
  1192             rset = session.execute('Any X WHERE X is %s' % etype)
  1190             rset = session.execute('Any X WHERE X is %s' % etype)