From f15e26c54ab8d0049b8f0fcc59e077d732cf4492 Mon Sep 17 00:00:00 2001 From: Griatch Date: Thu, 14 Jun 2012 21:10:40 +0200 Subject: [PATCH] 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). --- .../0001_rename_config_table_to_server_table.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/server/migrations/0001_rename_config_table_to_server_table.py b/src/server/migrations/0001_rename_config_table_to_server_table.py index afa461a04a..1cb74eb81c 100644 --- a/src/server/migrations/0001_rename_config_table_to_server_table.py +++ b/src/server/migrations/0001_rename_config_table_to_server_table.py @@ -5,16 +5,24 @@ from south.v2 import SchemaMigration from django.db import models, utils 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): no_dry_run = True 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") for conf in orm.ServerConfig.objects.all(): conf.db_value = pickle.dumps(conf.db_value) conf.save() - except Exception: #utils.DatabaseError: + else:# not HAS_SERVERCONF: # this will happen if we start db from scratch (the config # 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.