Database: add reload method; re-expand fields before reindexing

This commit is contained in:
Doug Blank 2016-05-03 08:07:42 -04:00
parent 9ab7b6cfc1
commit 331e6d4668
2 changed files with 11 additions and 0 deletions

View File

@ -739,6 +739,13 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
else:
return super().get_table_func(table, func)
def reload(self):
"""
Reload, and recreate tables (if necessary).
Useful after db.drop_tables()
"""
self.load(self._directory)
def load(self, directory, callback=None, mode=None,
force_schema_upgrade=False,
force_bsddb_upgrade=False,

View File

@ -1225,8 +1225,12 @@ class DBAPI(DbGeneric):
callback(5)
def rebuild_secondary(self, update):
# First, expand blob to individual fields:
self.rebuild_secondary_fields()
# Next, rebuild stats:
gstats = self.get_gender_stats()
self.genderStats = GenderStats(gstats)
# Rebuild all order_by fields:
## Rebuild place order_by:
self.dbapi.execute("""select blob_data from place;""")
row = self.dbapi.fetchone()