From 680d70a39b6df4094be380f4aaa249c172d2d64b Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Fri, 7 Jun 2024 12:27:38 +0300 Subject: [PATCH] fix: system info revision raises an error on startup --- ckanext/editable_config/shared.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ckanext/editable_config/shared.py b/ckanext/editable_config/shared.py index ade03df..0587d33 100644 --- a/ckanext/editable_config/shared.py +++ b/ckanext/editable_config/shared.py @@ -3,7 +3,7 @@ import datetime import logging from typing import Any, Collection, Iterable - +import sqlalchemy as sa from typing_extensions import TypedDict import ckan.plugins.toolkit as tk @@ -84,6 +84,10 @@ def convert_core_overrides(names: Iterable[str]): log.debug("Do not convert core overrides because plugin is not loaded yet") return + inspector = sa.inspect(model.meta.engine) + if inspector.has_table("system_info_revision"): + model.Session.execute(sa.delete(sa.table("system_info_revision"))) + q = model.Session.query(model.SystemInfo).filter( model.SystemInfo.key.in_(names), ) @@ -97,7 +101,6 @@ def convert_core_overrides(names: Iterable[str]): "options": options, }, ) - q.delete() model.Session.commit()