def update_db(): # Get current database build versions config = siteconfig.load_site_config() db_buildversion = config.get('BUILDVERSION', DEFAULT_BUILDVERSION) db_tt_buildversion = int(config.get('TT_BUILDVERSION', DEFAULT_TT_BUILDVERSION)) if (db_buildversion < code_buildversion or db_tt_buildversion < code_tt_buildversion): if db_buildversion < code_buildversion: logging.info("Upgrading Pootle database from schema version " "%d to %d", db_buildversion, code_buildversion) if db_tt_buildversion < code_tt_buildversion: logging.info("Upgrading TT database from schema version %d to %d", db_tt_buildversion, code_tt_buildversion) from pootle_misc.dbupdate import staggered_update for i in staggered_update(db_buildversion, db_tt_buildversion): pass logging.info("Database upgrade done, current schema versions:\n" "- Pootle: %d\n- Translate Toolkit: %d", code_buildversion, code_tt_buildversion) else: logging.info("No database upgrades required, current schema " "versions:\n- Pootle: %d\n- Translate Toolkit: %d", db_buildversion, db_tt_buildversion)
def update_db(): # Get current database build versions config = siteconfig.load_site_config() db_buildversion = config.get('BUILDVERSION', DEFAULT_BUILDVERSION) db_tt_buildversion = int( config.get('TT_BUILDVERSION', DEFAULT_TT_BUILDVERSION)) if (db_buildversion < code_buildversion or db_tt_buildversion < code_tt_buildversion): if db_buildversion < code_buildversion: logging.info( "Upgrading Pootle database from schema version " "%d to %d", db_buildversion, code_buildversion) if db_tt_buildversion < code_tt_buildversion: logging.info("Upgrading TT database from schema version %d to %d", db_tt_buildversion, code_tt_buildversion) from pootle_misc.dbupdate import staggered_update for i in staggered_update(db_buildversion, db_tt_buildversion): pass logging.info( "Database upgrade done, current schema versions:\n" "- Pootle: %d\n- Translate Toolkit: %d", code_buildversion, code_tt_buildversion) else: logging.info( "No database upgrades required, current schema " "versions:\n- Pootle: %d\n- Translate Toolkit: %d", db_buildversion, db_tt_buildversion)
def process_response(self, request, response): """ this should be the last response processor to run, detect dummy response with INSTALL_STATUS_CODE status code and start db install process""" if response.status_code == INSTALL_STATUS_CODE: return HttpResponse(dbinit.staggered_install(response.exception)) elif response.status_code == UPDATE_STATUS_CODE: return HttpResponse(dbupdate.staggered_update(response.db_buildversion, response.tt_buildversion)) else: return response
def update_db(): # get current database buildversion config = siteconfig.load_site_config() db_buildversion = config.get("BUILDVERSION", DEFAULT_BUILDVERSION) if db_buildversion < code_buildversion: logging.info("Upgrading database from schema version %d to %d", db_buildversion, code_buildversion) for i in staggered_update(db_buildversion, sys.maxint): pass logging.info("Database upgrade done, current schema version %d", code_buildversion) else: logging.info("No database upgrades required, current schema version %d", db_buildversion)
def update_db(): # get current database buildversion config = siteconfig.load_site_config() db_buildversion = config.get('BUILDVERSION', DEFAULT_BUILDVERSION) if db_buildversion < code_buildversion: logging.info("Upgrading database from schema version %d to %d", db_buildversion, code_buildversion) for i in staggered_update(db_buildversion): pass logging.info("Database upgrade done, current schema version %d", code_buildversion) else: logging.info("No database upgrades required, current schema version %d", db_buildversion)