New issue 217: upgrade-db fails to fix auth modules after rebranddb.py
https://bitbucket.org/conservancy/kallithea/issues/217/upgrade-db-fails-to-fix-auth-modules-after
Matthias Langhammer:
While upgrading from RhodeCode 1.7.1 to Kallithea 0.3.2 I faced the following
problem during the database migration:
```
***********************************
*** FIXING DEFAULT AUTH MODULES ***
***********************************
Traceback (most recent call last):
File "/tmp/rhodecodetest/system/bin/paster", line 11, in <module>
sys.exit(run())
File
"/tmp/rhodecodetest/system/local/lib/python2.7/site-packages/paste/script/command.py",
line 102, in run
invoke(command, command_name, options, args[1:])
File
"/tmp/rhodecodetest/system/local/lib/python2.7/site-packages/paste/script/command.py",
line 141, in invoke
exit_code = runner.run(args)
File
"/tmp/rhodecodetest/system/local/lib/python2.7/site-packages/kallithea/lib/utils.py",
line 752, in run
return super(BasePasterCommand, self).run(args[1:])
File
"/tmp/rhodecodetest/system/local/lib/python2.7/site-packages/paste/script/command.py",
line 236, in run
result = self.command()
File
"/tmp/rhodecodetest/system/local/lib/python2.7/site-packages/kallithea/lib/dbmigrate/__init__.py",
line 57, in command
dbmanage.upgrade()
File
"/tmp/rhodecodetest/system/local/lib/python2.7/site-packages/kallithea/lib/db_manage.py",
line 175, in upgrade
api.upgrade(db_uri, repository_path, step)
File
"/tmp/rhodecodetest/system/local/lib/python2.7/site-packages/kallithea/lib/dbmigrate/migrate/versioning/api.py",
line 186, in upgrade
return _migrate(url, repository, version, upgrade=True, err=err, **opts)
File "<decorator-gen-16>", line 2, in _migrate
File
"/tmp/rhodecodetest/system/local/lib/python2.7/site-packages/kallithea/lib/dbmigrate/migrate/versioning/util/__init__.py",
line 159, in with_engine
return f(*a, **kw)
File
"/tmp/rhodecodetest/system/local/lib/python2.7/site-packages/kallithea/lib/dbmigrate/migrate/versioning/api.py",
line 366, in _migrate
schema.runchange(ver, change, changeset.step)
File
"/tmp/rhodecodetest/system/local/lib/python2.7/site-packages/kallithea/lib/dbmigrate/migrate/versioning/schema.py",
line 92, in runchange
change.run(self.engine, step)
File
"/tmp/rhodecodetest/system/local/lib/python2.7/site-packages/kallithea/lib/dbmigrate/migrate/versioning/script/py.py",
line 145, in run
script_func(engine)
File
"/tmp/rhodecodetest/system/lib/python2.7/site-packages/kallithea/lib/dbmigrate/versions/018_version_2_0_0.py",
line 24, in upgrade
fixups(db_2_0_0, meta.Session)
File
"/tmp/rhodecodetest/system/lib/python2.7/site-packages/kallithea/lib/dbmigrate/versions/018_version_2_0_0.py",
line 69, in fixups
setting = models.Setting(name, old_setting.app_settings_value, t)
AttributeError: 'NoneType' object has no attribute 'app_settings_value'
```
The problem appears while LDAP settings (which did not exist in the old
database) are converted to the new format with 'auth_' as prefix.
The script crashes when trying to access the attribute 'app_settings_value'
from an old_setting which does not exist.
So instead of using the non-existing old value, the default value 'v' should be
used.
I fixed this by editing the file lib/dbmigrate/versions/018_version_2_0_0.py .
I replaced
```
#!python
for k, v, t in old_ldap:
old_setting = models.Setting.get_by_name(k)
name = 'auth_%s' % k
setting = models.Setting.get_by_name(name)
if not setting:
# if we don't have this option create it
setting = models.Setting(name, old_setting.app_settings_value, t)
```
with
```
#!python
for k, v, t in old_ldap:
old_setting = models.Setting.get_by_name(k)
name = 'auth_%s' % k
setting = models.Setting.get_by_name(name)
if not setting:
# if we don't have this option create it
setting = models.Setting(name, v, t)
```
With this patch I was able to compelte the migration.
_______________________________________________
kallithea-general mailing list
[email protected]
http://lists.sfconservancy.org/mailman/listinfo/kallithea-general