From 62c709e3684c9dded6ad85ab8d6f5a56d4b40263 Mon Sep 17 00:00:00 2001 From: Mondo Diaz Date: Tue, 3 Feb 2026 11:19:50 -0600 Subject: [PATCH] Remove superuser-only session_replication_role from factory reset --- backend/app/routes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/routes.py b/backend/app/routes.py index a910601..decd1d0 100644 --- a/backend/app/routes.py +++ b/backend/app/routes.py @@ -7465,6 +7465,8 @@ def factory_reset( try: # Step 1: Drop all tables in public schema + # Note: CASCADE handles foreign key constraints without needing + # superuser privileges (session_replication_role requires superuser) logger.info("Dropping all database tables...") drop_result = db.execute( text(""" @@ -7473,12 +7475,10 @@ def factory_reset( r RECORD; table_count INT := 0; BEGIN - SET session_replication_role = 'replica'; FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = 'public') LOOP EXECUTE 'DROP TABLE IF EXISTS public.' || quote_ident(r.tablename) || ' CASCADE'; table_count := table_count + 1; END LOOP; - SET session_replication_role = 'origin'; RAISE NOTICE 'Dropped % tables', table_count; END $$; """)