From a1cda0d2dcbcef8dcecf97803d1a42d22ecb3b4d Mon Sep 17 00:00:00 2001 From: mattiagiupponi Date: Tue, 13 Feb 2024 17:10:32 +0100 Subject: [PATCH 1/3] [Fixes #223] Migration error 0005_fixup_dynamic_shema_table_names --- .../0005_fixup_dynamic_shema_table_names.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/importer/migrations/0005_fixup_dynamic_shema_table_names.py b/importer/migrations/0005_fixup_dynamic_shema_table_names.py index e216c8ae..300eb547 100644 --- a/importer/migrations/0005_fixup_dynamic_shema_table_names.py +++ b/importer/migrations/0005_fixup_dynamic_shema_table_names.py @@ -1,26 +1,23 @@ from django.db import migrations import logging from django.db import ProgrammingError +from django.db import connections logger = logging.getLogger(__name__) def fixup_table_name(apps, schema_editor): try: - schema = apps.get_model("dynamic_models", "ModelSchema") - for val in schema.objects.all(): - if val.name != val.db_table_name: - val.db_table_name = val.name - val.save() - except ProgrammingError as e: """ - The dynamic model should exists to apply the above migration. + The dynamic model should exists to apply the migration. In case it does not exists we can skip it """ - if 'relation "dynamic_models_modelschema" does not exist' in e.args[0]: - logging.debug("Dynamic model does not exists yet, skipping") - return - raise e + if 'dynamic_models_modelschema' in schema_editor.connection.introspection.table_names(): + schema = apps.get_model("dynamic_models", "ModelSchema") + for val in schema.objects.all(): + if val.name != val.db_table_name: + val.db_table_name = val.name + val.save() except Exception as e: raise e From 6fd374121cff3bc9cd6b61902b4b01b74cccc1c7 Mon Sep 17 00:00:00 2001 From: mattiagiupponi <51856725+mattiagiupponi@users.noreply.github.com> Date: Wed, 14 Feb 2024 10:40:50 +0100 Subject: [PATCH 2/3] Update __init__.py --- importer/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/importer/__init__.py b/importer/__init__.py index 759393c4..1018fa0f 100644 --- a/importer/__init__.py +++ b/importer/__init__.py @@ -20,7 +20,7 @@ project_dir = os.path.dirname(os.path.abspath(__file__)) -VERSION = (1, 0, 6) +VERSION = (1, 0, 7) __version__ = ".".join([str(i) for i in VERSION]) __author__ = "geosolutions-it" __email__ = "info@geosolutionsgroup.com" From ee511da8c70e07cb3269372b3f46d3d2c8a88b7f Mon Sep 17 00:00:00 2001 From: mattiagiupponi <51856725+mattiagiupponi@users.noreply.github.com> Date: Wed, 14 Feb 2024 10:42:48 +0100 Subject: [PATCH 3/3] Update __init__.py --- importer/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/importer/__init__.py b/importer/__init__.py index 1018fa0f..759393c4 100644 --- a/importer/__init__.py +++ b/importer/__init__.py @@ -20,7 +20,7 @@ project_dir = os.path.dirname(os.path.abspath(__file__)) -VERSION = (1, 0, 7) +VERSION = (1, 0, 6) __version__ = ".".join([str(i) for i in VERSION]) __author__ = "geosolutions-it" __email__ = "info@geosolutionsgroup.com"