[migration] fix rename_entity_type: avoid removal of attributes on the new entity type from the schema during migration stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 17 Aug 2010 15:25:17 +0200
branchstable
changeset 6116 2530e9c45296
parent 6115 56ec278b843e
child 6117 f3fdfcbda54b
[migration] fix rename_entity_type: avoid removal of attributes on the new entity type from the schema during migration
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)