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.pull/3/head
parent
a7e1e25cf4
commit
d63b54610b
|
@ -154,10 +154,6 @@ MAX_SESSION_IDLE_TIME = 60
|
|||
# User account and settings storage
|
||||
##########################################################################
|
||||
|
||||
# The schema version number for the configuration database
|
||||
# DO NOT CHANGE UNLESS YOU ARE A PGADMIN DEVELOPER!!
|
||||
SETTINGS_SCHEMA_VERSION = 13
|
||||
|
||||
# The default path to the SQLite database used to store user accounts and
|
||||
# settings. This default places the file in the same directory as this
|
||||
# config file, but generates an absolute path for use througout the app.
|
||||
|
|
|
@ -23,6 +23,11 @@ if sys.path[0] != root:
|
|||
import config
|
||||
from pgadmin import create_app
|
||||
|
||||
# Get the config database schema version. We store this in pgadmin.model
|
||||
# as it turns out that putting it in the config files isn't a great idea
|
||||
from pgadmin.model import SCHEMA_VERSION
|
||||
config.SETTINGS_SCHEMA_VERSION = SCHEMA_VERSION
|
||||
|
||||
##########################################################################
|
||||
# Sanity checks
|
||||
##########################################################################
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -26,6 +26,11 @@ from pgadmin.model import db, Role, User, Server, \
|
|||
# Configuration settings
|
||||
import config
|
||||
|
||||
# Get the config database schema version. We store this in pgadmin.model
|
||||
# as it turns out that putting it in the config files isn't a great idea
|
||||
from pgadmin.model import SCHEMA_VERSION
|
||||
config.SETTINGS_SCHEMA_VERSION = SCHEMA_VERSION
|
||||
|
||||
# If script is running under python2 then change the behaviour of functions
|
||||
if hasattr(__builtins__, 'raw_input'):
|
||||
input = raw_input
|
||||
|
|
Loading…
Reference in New Issue