server/migractions.py
branchstable
changeset 6074 f2580c7abc26
parent 6073 bf684f1022bf
child 6075 6ebecb217efe
equal deleted inserted replaced
6073:bf684f1022bf 6074:f2580c7abc26
   874             # backport is / is_instance_of relation to new type
   874             # backport is / is_instance_of relation to new type
   875             for rtype in ('is', 'is_instance_of'):
   875             for rtype in ('is', 'is_instance_of'):
   876                 self.sqlexec('UPDATE %s_relation SET eid_to=%s WHERE eid_to=%s'
   876                 self.sqlexec('UPDATE %s_relation SET eid_to=%s WHERE eid_to=%s'
   877                              % (rtype, new.eid, oldeid), ask_confirm=False)
   877                              % (rtype, new.eid, oldeid), ask_confirm=False)
   878             # delete relations using SQL to avoid relations content removal
   878             # delete relations using SQL to avoid relations content removal
   879             # triggered by schema synchronization hooks
   879             # triggered by schema synchronization hooks. Should add deleted eids
       
   880             # into pending eids else we may get some validation error on commit
       
   881             # since integrity hooks may think some required relation is
       
   882             # missing...
       
   883             pending = self.session.transaction_data.setdefault('pendingeids', set())
       
   884             for eid, in self.sqlexec('SELECT cw_eid FROM cw_CWRelation '
       
   885                                      'WHERE cw_from_entity=%(eid)s OR cw_to_entity=%(eid)s',
       
   886                                      {'eid': oldeid}, ask_confirm=False):
       
   887                 pending.add(eid)
   880             self.sqlexec('DELETE FROM cw_CWRelation '
   888             self.sqlexec('DELETE FROM cw_CWRelation '
   881                          'WHERE cw_from_entity=%(eid)s OR cw_to_entity=%(eid)s',
   889                          'WHERE cw_from_entity=%(eid)s OR cw_to_entity=%(eid)s',
   882                          {'eid': oldeid}, ask_confirm=False)
   890                          {'eid': oldeid}, ask_confirm=False)
   883             # remove the old type: use rql to propagate deletion
   891             # remove the old type: use rql to propagate deletion
   884             self.rqlexec('DELETE CWEType ET WHERE ET name %(on)s', {'on': oldname},
   892             self.rqlexec('DELETE CWEType ET WHERE ET name %(on)s', {'on': oldname},