Move the config database schema version out of the configuration file and into the model class.

Turns out using the config file isn't a good idea if users copy config.py to config_local.py, as it prevents upgrades to the database. This has the added side-effect of simplifying future changes, as you only need to edit 2 files to modify the config DB now, not 3.
This commit is contained in:
Dave Page
2016-06-24 12:50:52 +01:00
parent a7e1e25cf4
commit d63b54610b
4 changed files with 27 additions and 5 deletions

View File

@@ -12,7 +12,7 @@
If any of the models are updated, you (yes, you, the developer) MUST do two
things:
1) Increment SETTINGS_SCHEMA_VERSION in config.py
1) Increment SCHEMA_VERSION below
2) Modify setup.py to ensure that the appropriate changes are made to the
config database to upgrade it to the new version.
@@ -21,6 +21,22 @@ things:
from flask.ext.security import UserMixin, RoleMixin
from flask.ext.sqlalchemy import SQLAlchemy
##########################################################################
#
# The schema version is used to track when upgrades are needed to the
# configuration database. Increment this whenever changes are made to the
# model or data, AND ensure the upgrade code is added to setup.py
#
##########################################################################
SCHEMA_VERSION = 13
##########################################################################
#
# And now we return to our regularly scheduled programming:
#
##########################################################################
db = SQLAlchemy()
# Define models