def db_perform_data_update(store): prv = PrivateFactory(store) stored_ver = prv.get_val('version') t = (stored_ver, __version__) # Catch all failures if stored_ver != __version__: prv.set_val('version', __version__) appdata = db_update_appdata(store) config.update_defaults(store) l10n.update_defaults(store, appdata) db_fix_fields_attrs(store) ok = config.is_cfg_valid(store) if not ok: m = 'Error: the system is not stable, update failed from %s to %s' % t raise DatabaseIntegrityError(m)
def db_perform_data_update(store): prv = PrivateFactory(store) stored_ver = prv.get_val('version') t = (stored_ver, __version__) if stored_ver != __version__: prv.set_val('version', __version__) # The below commands can change the current store based on the what is # currently stored in the DB. appdata = db_update_appdata(store) l10n.update_defaults(store, appdata) config.update_defaults(store) db_fix_fields_attrs(store) ok = config.is_cfg_valid(store) if not ok: m = 'Error: the system is not stable, update failed from %s to %s' % t raise Exception(m)
def perform_data_update(db_file): engine = get_engine('sqlite+pysqlite:////' + db_file, foreign_keys=False) session = sessionmaker(bind=engine)() enabled_languages = [lang.name for lang in session.query(models.EnabledLanguage)] removed_languages = list(set(enabled_languages) - set(LANGUAGES_SUPPORTED_CODES)) if removed_languages: removed_languages.sort() removed_languages = ', '.join(removed_languages) raise Exception("FATAL: cannot complete the upgrade because the support for some of the enabled languages is currently incomplete (%s)\n" "Read about how to handle this condition at: https://github.com/globaleaks/GlobaLeaks/wiki/Upgrade-Guide#lang-drop" % removed_languages) try: prv = ConfigFactory(session, 1, 'node') stored_ver = prv.get_val(u'version') if stored_ver != __version__: prv.set_val(u'version', __version__) # The below commands can change the current store based on the what is # currently stored in the DB. for tid in [t[0] for t in session.query(models.Tenant.id)]: appdata = load_appdata() config.update_defaults(session, tid) l10n.update_defaults(session, tid, appdata) db_update_defaults(session) db_fix_fields_attrs(session) session.commit() except: session.rollback() raise finally: session.close()