Skip to content

Commit 0a432c8

Browse files
committed
Fix drop_before_all: revert to NOT LIKE pattern and add new migration with regex for proper history table exclusion
1 parent 5e304f9 commit 0a432c8

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.1.25
2+
3+
- Fix drop_before_all test fixture to properly exclude history tables using regex pattern
4+
15
## 0.1.24
26

37
- Fix build

aidbox_python_sdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__title__ = "aidbox-python-sdk"
2-
__version__ = "0.1.24"
2+
__version__ = "0.1.25"
33
__author__ = "beda.software"
44
__license__ = "None"
55
__copyright__ = "Copyright 2024 beda.software"

aidbox_python_sdk/db_migrations.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@
2020
"sql": """
2121
DROP FUNCTION IF EXISTS drop_before_all(integer);
2222
23+
CREATE FUNCTION drop_before_all(integer) RETURNS VOID AS $$
24+
declare
25+
e record;
26+
BEGIN
27+
FOR e IN (
28+
SELECT table_name
29+
FROM information_schema.columns
30+
WHERE column_name = 'txid' AND table_schema = 'public' AND table_name NOT LIKE '%_history'
31+
) LOOP
32+
EXECUTE 'DELETE FROM "' || e.table_name || '" WHERE txid > ' || $1 ;
33+
END LOOP;
34+
END;
35+
36+
$$ LANGUAGE plpgsql;""",
37+
},
38+
{
39+
"id": "20251209_fix_drop_before_all_history",
40+
"sql": """
41+
DROP FUNCTION IF EXISTS drop_before_all(integer);
42+
2343
CREATE FUNCTION drop_before_all(integer) RETURNS VOID AS $$
2444
declare
2545
e record;

0 commit comments

Comments
 (0)