# HG changeset patch # User Sylvain Thénault # Date 1282051517 -7200 # Node ID 2530e9c45296c0e97e967ba0edc46b84bb0e4555 # Parent 56ec278b843e9f08b12c176f121eefb40398d3a8 [migration] fix rename_entity_type: avoid removal of attributes on the new entity type from the schema during migration diff -r 56ec278b843e -r 2530e9c45296 server/migractions.py --- a/server/migractions.py Tue Aug 17 15:23:59 2010 +0200 +++ b/server/migractions.py Tue Aug 17 15:25:17 2010 +0200 @@ -891,13 +891,16 @@ # since integrity hooks may think some required relation is # missing... pending = self.session.transaction_data.setdefault('pendingeids', set()) - for eid, in self.sqlexec('SELECT cw_eid FROM cw_CWRelation ' - 'WHERE cw_from_entity=%(eid)s OR cw_to_entity=%(eid)s', - {'eid': oldeid}, ask_confirm=False): - pending.add(eid) - self.sqlexec('DELETE FROM cw_CWRelation ' - 'WHERE cw_from_entity=%(eid)s OR cw_to_entity=%(eid)s', - {'eid': oldeid}, ask_confirm=False) + for rdeftype in ('CWRelation', 'CWAttribute'): + for eid, in self.sqlexec('SELECT cw_eid FROM cw_%s ' + 'WHERE cw_from_entity=%%(eid)s OR ' + ' cw_to_entity=%%(eid)s' % rdeftype, + {'eid': oldeid}, ask_confirm=False): + pending.add(eid) + self.sqlexec('DELETE FROM cw_%s ' + 'WHERE cw_from_entity=%%(eid)s OR ' + 'cw_to_entity=%%(eid)s' % rdeftype, + {'eid': oldeid}, ask_confirm=False) # remove the old type: use rql to propagate deletion self.rqlexec('DELETE CWEType ET WHERE ET name %(on)s', {'on': oldname}, ask_confirm=False)