# HG changeset patch # User Sylvain Thénault # Date 1311343085 -7200 # Node ID 4f5ab60e71cc0d8757847a429cfaa5b059e3af55 # Parent 6580b5a0f1cf1d9a20a2905100dc8e20e1a749f8 [c-c db-check] add some sql queries to fix cw_source/is/is_instance relations according to data in the entities table diff -r 6580b5a0f1cf -r 4f5ab60e71cc server/checkintegrity.py --- a/server/checkintegrity.py Fri Jul 22 15:41:17 2011 +0200 +++ b/server/checkintegrity.py Fri Jul 22 15:58:05 2011 +0200 @@ -188,6 +188,18 @@ if fix: session.system_sql('DELETE FROM entities WHERE eid=%s;' % eid) notify_fixed(fix) + session.system_sql('INSERT INTO cw_source_relation (eid_from, eid_to) ' + 'SELECT e.eid, s.cw_eid FROM entities as e, cw_CWSource as s ' + 'WHERE s.cw_name=e.asource AND NOT EXISTS(SELECT 1 FROM cw_source_relation as cs ' + ' WHERE cs.eid_from=e.eid AND cs.eid_to=s.cw_eid)') + session.system_sql('INSERT INTO is_relation (eid_from, eid_to) ' + 'SELECT e.eid, s.cw_eid FROM entities as e, cw_CWEType as s ' + 'WHERE s.cw_name=e.type AND NOT EXISTS(SELECT 1 FROM is_relation as cs ' + ' WHERE cs.eid_from=e.eid AND cs.eid_to=s.cw_eid)') + session.system_sql('INSERT INTO is_instance_of_relation (eid_from, eid_to) ' + 'SELECT e.eid, s.cw_eid FROM entities as e, cw_CWEType as s ' + 'WHERE s.cw_name=e.type AND NOT EXISTS(SELECT 1 FROM is_instance_of_relation as cs ' + ' WHERE cs.eid_from=e.eid AND cs.eid_to=s.cw_eid)') print 'Checking entities tables' for eschema in schema.entities(): if eschema.final: