server/checkintegrity.py
changeset 3720 5376aaadd16b
parent 3417 fb17a54b358c
parent 3689 deb13e88e037
child 4252 6c4f109c2b03
equal deleted inserted replaced
3678:29f74716fd70 3720:5376aaadd16b
    81     repo.config.disabled_hooks_categories.add('metadata')
    81     repo.config.disabled_hooks_categories.add('metadata')
    82     repo.config.disabled_hooks_categories.add('integrity')
    82     repo.config.disabled_hooks_categories.add('integrity')
    83     repo.do_fti = True  # ensure full-text indexation is activated
    83     repo.do_fti = True  # ensure full-text indexation is activated
    84     etypes = set()
    84     etypes = set()
    85     for eschema in schema.entities():
    85     for eschema in schema.entities():
    86         if eschema.is_final():
    86         if eschema.final:
    87             continue
    87             continue
    88         indexable_attrs = tuple(eschema.indexable_attributes()) # generator
    88         indexable_attrs = tuple(eschema.indexable_attributes()) # generator
    89         if not indexable_attrs:
    89         if not indexable_attrs:
    90             continue
    90             continue
    91         for container in etype_fti_containers(eschema):
    91         for container in etype_fti_containers(eschema):
   159                 print >> sys.stderr, ' [FIXED]'
   159                 print >> sys.stderr, ' [FIXED]'
   160             else:
   160             else:
   161                 print >> sys.stderr
   161                 print >> sys.stderr
   162     print 'Checking entities tables'
   162     print 'Checking entities tables'
   163     for eschema in schema.entities():
   163     for eschema in schema.entities():
   164         if eschema.is_final():
   164         if eschema.final:
   165             continue
   165             continue
   166         table = SQL_PREFIX + eschema.type
   166         table = SQL_PREFIX + eschema.type
   167         column = SQL_PREFIX +  'eid'
   167         column = SQL_PREFIX +  'eid'
   168         cursor = session.system_sql('SELECT %s FROM %s;' % (column, table))
   168         cursor = session.system_sql('SELECT %s FROM %s;' % (column, table))
   169         for row in cursor.fetchall():
   169         for row in cursor.fetchall():
   191 
   191 
   192 def check_relations(schema, session, eids, fix=1):
   192 def check_relations(schema, session, eids, fix=1):
   193     """check all relations registered in the repo system table"""
   193     """check all relations registered in the repo system table"""
   194     print 'Checking relations'
   194     print 'Checking relations'
   195     for rschema in schema.relations():
   195     for rschema in schema.relations():
   196         if rschema.is_final() or rschema in PURE_VIRTUAL_RTYPES:
   196         if rschema.final or rschema in PURE_VIRTUAL_RTYPES:
   197             continue
   197             continue
   198         if rschema.inlined:
   198         if rschema.inlined:
   199             for subjtype in rschema.subjects():
   199             for subjtype in rschema.subjects():
   200                 table = SQL_PREFIX + str(subjtype)
   200                 table = SQL_PREFIX + str(subjtype)
   201                 column = SQL_PREFIX +  str(rschema)
   201                 column = SQL_PREFIX +  str(rschema)