Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_new_app_version(self):
"""Return the version of the application we should upgrade to (normalized version)"""
return NormalizedVersion(self._suggest_normalized_version(__version__))
def get_current_db_version(self):
"""Return the current version of the database"""
db_version = self._sql_execute("SELECT db_version FROM core_system_info").fetchone()[0]
if db_version is None or db_version == '':
# Should only happen for the first upgrade using this script
return NormalizedVersion('0.1.0')
else:
return NormalizedVersion(self._suggest_normalized_version(db_version))
def get_current_app_version(self):
"""Return the current version of the application"""
try:
app_version = self._sql_execute("SELECT app_version FROM core_system_info").fetchone()[0]
# Should only happen if the 'app_version' column doesn't exist (first application upgrade using this script)
if app_version is None or app_version == '':
app_version = NormalizedVersion('0.1.0')
return NormalizedVersion(self._suggest_normalized_version(app_version))
except Exception:
return NormalizedVersion('0.1.0')
def app_upgrade(upgrade_instance):
"""Eventually upgrade the application (depending on the current version number)
@param upgrade_instance : instance of the Upgrade object
@return true if an upgrade was done
"""
old_app_version = upgrade_instance.get_current_app_version()
new_app_version = upgrade_instance.get_new_app_version()
if new_app_version == NormalizedVersion('0.2.0'):
if old_app_version == NormalizedVersion('0.1.0'):
_upgrade_app_from_0_1_0_to_0_2_0(upgrade_instance)
return True
return False
def get_current_app_version(self):
"""Return the current version of the application"""
try:
app_version = self._sql_execute("SELECT app_version FROM core_system_info").fetchone()[0]
# Should only happen if the 'app_version' column doesn't exist (first application upgrade using this script)
if app_version is None or app_version == '':
app_version = NormalizedVersion('0.1.0')
return NormalizedVersion(self._suggest_normalized_version(app_version))
except Exception:
return NormalizedVersion('0.1.0')
def get_current_db_version(self):
"""Return the current version of the database"""
db_version = self._sql_execute("SELECT db_version FROM core_system_info").fetchone()[0]
if db_version is None or db_version == '':
# Should only happen for the first upgrade using this script
return NormalizedVersion('0.1.0')
else:
return NormalizedVersion(self._suggest_normalized_version(db_version))
def get_new_db_version(self):
"""Return the version of the database we should upgrade to (normalized version)"""
return NormalizedVersion(self._suggest_normalized_version(DB_VERSION))