diff --git a/CHANGELOG.md b/CHANGELOG.md index 173c381..8882d9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.25 + +- Fix drop_before_all test fixture to properly exclude history tables using regex pattern + ## 0.1.24 - Fix build diff --git a/aidbox_python_sdk/__init__.py b/aidbox_python_sdk/__init__.py index a0b761e..587bb5f 100644 --- a/aidbox_python_sdk/__init__.py +++ b/aidbox_python_sdk/__init__.py @@ -1,5 +1,5 @@ __title__ = "aidbox-python-sdk" -__version__ = "0.1.24" +__version__ = "0.1.25" __author__ = "beda.software" __license__ = "None" __copyright__ = "Copyright 2024 beda.software" diff --git a/aidbox_python_sdk/db_migrations.py b/aidbox_python_sdk/db_migrations.py index 3348540..408e01e 100644 --- a/aidbox_python_sdk/db_migrations.py +++ b/aidbox_python_sdk/db_migrations.py @@ -20,6 +20,26 @@ "sql": """ DROP FUNCTION IF EXISTS drop_before_all(integer); +CREATE FUNCTION drop_before_all(integer) RETURNS VOID AS $$ +declare +e record; +BEGIN +FOR e IN ( + SELECT table_name + FROM information_schema.columns + WHERE column_name = 'txid' AND table_schema = 'public' AND table_name NOT LIKE '%_history' +) LOOP + EXECUTE 'DELETE FROM "' || e.table_name || '" WHERE txid > ' || $1 ; +END LOOP; +END; + +$$ LANGUAGE plpgsql;""", + }, + { + "id": "20251209_fix_drop_before_all_history", + "sql": """ +DROP FUNCTION IF EXISTS drop_before_all(integer); + CREATE FUNCTION drop_before_all(integer) RETURNS VOID AS $$ declare e record;