misc/migration/3.3.5_Any.py
branchstable
changeset 2588 3a590ff82e99
child 8798 cdab3aadc679
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/migration/3.3.5_Any.py	Fri Jul 31 14:18:53 2009 +0200
@@ -0,0 +1,8 @@
+# some entities have been added before schema entities, fix the 'is' and
+# 'is_instance_of' relations
+for rtype in ('is', 'is_instance_of'):
+    sql('INSERT INTO %s_relation '
+        'SELECT X.eid, ET.cw_eid FROM entities as X, cw_CWEType as ET '
+        'WHERE X.type=ET.cw_name AND NOT EXISTS('
+        '      SELECT 1 from is_relation '
+        '      WHERE eid_from=X.eid AND eid_to=ET.cw_eid)' % rtype)