diff --git a/aidbox_python_sdk/db_migrations.py b/aidbox_python_sdk/db_migrations.py index fbb47be..45c46df 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": "20251126_fix_drop_before_all_for_history_resources", + "sql": """ +DROP FUNCTION IF EXISTS drop_before_all(integer); + CREATE FUNCTION drop_before_all(integer) RETURNS VOID AS $$ declare e record;