Skip to content

Commit add0806

Browse files
committed
Fix drop_before_all migration
1 parent 4d141dc commit add0806

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

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": "20251126_fix_drop_before_all_for_history_resources",
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)