From 21604259a488bafd45c8b76868fa210ef843ce6a Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 4 Aug 2022 16:09:02 +0200 Subject: [PATCH] SQL truncate_tables: preserve alembic_version --- app/models/raw_sql_init.py | 3 ++- migrations/versions/993ce4a01d57_scodoc_9_0_3.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/raw_sql_init.py b/app/models/raw_sql_init.py index 6cfde9d9..58094687 100644 --- a/app/models/raw_sql_init.py +++ b/app/models/raw_sql_init.py @@ -32,7 +32,8 @@ DECLARE SELECT tablename FROM pg_tables WHERE tableowner = username AND schemaname = 'public' AND tablename <> 'notes_semestres' - AND tablename <> 'notes_form_modalites'; + AND tablename <> 'notes_form_modalites' + AND tablename <> 'alembic_version'; BEGIN FOR stmt IN statements LOOP EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;'; diff --git a/migrations/versions/993ce4a01d57_scodoc_9_0_3.py b/migrations/versions/993ce4a01d57_scodoc_9_0_3.py index c1e87c93..9cc85984 100644 --- a/migrations/versions/993ce4a01d57_scodoc_9_0_3.py +++ b/migrations/versions/993ce4a01d57_scodoc_9_0_3.py @@ -34,7 +34,8 @@ DECLARE SELECT tablename FROM pg_tables WHERE tableowner = username AND schemaname = 'public' AND tablename <> 'notes_semestres' - AND tablename <> 'notes_form_modalites'; + AND tablename <> 'notes_form_modalites' + AND tablename <> 'alembic_version'; BEGIN FOR stmt IN statements LOOP EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;';