server/migractions.py
branchstable
changeset 6116 2530e9c45296
parent 6115 56ec278b843e
child 6117 f3fdfcbda54b
equal deleted inserted replaced
6115:56ec278b843e 6116:2530e9c45296
   889             # triggered by schema synchronization hooks. Should add deleted eids
   889             # triggered by schema synchronization hooks. Should add deleted eids
   890             # into pending eids else we may get some validation error on commit
   890             # into pending eids else we may get some validation error on commit
   891             # since integrity hooks may think some required relation is
   891             # since integrity hooks may think some required relation is
   892             # missing...
   892             # missing...
   893             pending = self.session.transaction_data.setdefault('pendingeids', set())
   893             pending = self.session.transaction_data.setdefault('pendingeids', set())
   894             for eid, in self.sqlexec('SELECT cw_eid FROM cw_CWRelation '
   894             for rdeftype in ('CWRelation', 'CWAttribute'):
   895                                      'WHERE cw_from_entity=%(eid)s OR cw_to_entity=%(eid)s',
   895                 for eid, in self.sqlexec('SELECT cw_eid FROM cw_%s '
   896                                      {'eid': oldeid}, ask_confirm=False):
   896                                          'WHERE cw_from_entity=%%(eid)s OR '
   897                 pending.add(eid)
   897                                          ' cw_to_entity=%%(eid)s' % rdeftype,
   898             self.sqlexec('DELETE FROM cw_CWRelation '
   898                                          {'eid': oldeid}, ask_confirm=False):
   899                          'WHERE cw_from_entity=%(eid)s OR cw_to_entity=%(eid)s',
   899                     pending.add(eid)
   900                          {'eid': oldeid}, ask_confirm=False)
   900                 self.sqlexec('DELETE FROM cw_%s '
       
   901                              'WHERE cw_from_entity=%%(eid)s OR '
       
   902                              'cw_to_entity=%%(eid)s' % rdeftype,
       
   903                              {'eid': oldeid}, ask_confirm=False)
   901             # remove the old type: use rql to propagate deletion
   904             # remove the old type: use rql to propagate deletion
   902             self.rqlexec('DELETE CWEType ET WHERE ET name %(on)s', {'on': oldname},
   905             self.rqlexec('DELETE CWEType ET WHERE ET name %(on)s', {'on': oldname},
   903                          ask_confirm=False)
   906                          ask_confirm=False)
   904         else:
   907         else:
   905             self.rqlexec('SET ET name %(newname)s WHERE ET is CWEType, ET name %(on)s',
   908             self.rqlexec('SET ET name %(newname)s WHERE ET is CWEType, ET name %(on)s',