Fix of migration to remove a bogus FATAL error during migration. This also fixes a one error in the chain of errors reported by postgresql databases (those still fail on a latter point, alas).
This commit is contained in:
parent
2d46d0306b
commit
f15e26c54a
1 changed files with 10 additions and 2 deletions
|
|
@ -5,16 +5,24 @@ from south.v2 import SchemaMigration
|
||||||
from django.db import models, utils
|
from django.db import models, utils
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
|
HAS_CONFIGVAL = True
|
||||||
|
try: from src.server.models import ConfigValue
|
||||||
|
except ImportError: HAS_CONFIGVAL = False
|
||||||
|
HAS_SERVERCONF = True
|
||||||
|
try: from src.server.models import ServerConfig
|
||||||
|
except ImportError: HAS_SERVERCONF = False
|
||||||
|
|
||||||
class Migration(SchemaMigration):
|
class Migration(SchemaMigration):
|
||||||
|
|
||||||
no_dry_run = True
|
no_dry_run = True
|
||||||
def forwards(self, orm):
|
def forwards(self, orm):
|
||||||
try:
|
if HAS_CONFIGVAL:# and not HAS_SERVERCONF:
|
||||||
|
# this means we have to rename the old one
|
||||||
db.rename_table("config_configvalue", "server_serverconfig")
|
db.rename_table("config_configvalue", "server_serverconfig")
|
||||||
for conf in orm.ServerConfig.objects.all():
|
for conf in orm.ServerConfig.objects.all():
|
||||||
conf.db_value = pickle.dumps(conf.db_value)
|
conf.db_value = pickle.dumps(conf.db_value)
|
||||||
conf.save()
|
conf.save()
|
||||||
except Exception: #utils.DatabaseError:
|
else:# not HAS_SERVERCONF:
|
||||||
# this will happen if we start db from scratch (the config
|
# this will happen if we start db from scratch (the config
|
||||||
# app will then already be gone and no data is to be transferred)
|
# app will then already be gone and no data is to be transferred)
|
||||||
# So instead of renaming the old we instead have to manually create the new model.
|
# So instead of renaming the old we instead have to manually create the new model.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue