##// END OF EJS Templates
fix(caching): fixed problems with Cache query for users....
fix(caching): fixed problems with Cache query for users. The old way of querying caused the user get query to be always cached, and returning old results even in 2fa forms. The new limited query doesn't cache the user object resolving issues

File last commit:

r5042:4c5af799 default
r5365:ae8a165b default
Show More
054_version_4_1_0.py
55 lines | 1.3 KiB | text/x-python | PythonLexer
import logging
from collections import namedtuple
from rhodecode.lib.dbmigrate.versions import _reset_base
from rhodecode.model import init_model_encryption, meta
log = logging.getLogger(__name__)
def upgrade(migrate_engine):
"""
Upgrade operations go here.
Don't create your own engine; bind migrate_engine to your metadata
"""
_reset_base(migrate_engine)
from rhodecode.lib.dbmigrate.schema import db_3_7_0_0
init_model_encryption(db_3_7_0_0)
fixups(db_3_7_0_0, meta.Session)
def downgrade(migrate_engine):
pass
AUTH_PLUGINS_SETTING = "auth_plugins"
EXTERN_TYPE_RENAME_MAP = {
'container': 'headers',
}
# Only used for logging purposes.
RenameExternTypeOperation = namedtuple(
'RenameExternTypeOperation', ['user', 'old', 'new'])
def fixups(models, Session):
operations = []
# Rename the extern_type attribute
query = models.User.query().filter(
models.User.extern_type.in_(EXTERN_TYPE_RENAME_MAP.keys()))
for user in query:
old = user.extern_type
new = EXTERN_TYPE_RENAME_MAP[old]
user.extern_type = new
Session.add(user)
operations.append(RenameExternTypeOperation(user, old, new))
log.info("Migration of users 'extern_type' attribute.")
for op in operations:
log.info("%s", op)
Session().commit()