[migration] fix rename_entity_type: avoid removal of attributes on the new entity type from the schema during migration
--- 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)