SQL truncate_tables: preserve alembic_version

This commit is contained in:
Emmanuel Viennet 2022-08-04 16:09:02 +02:00
parent d389c54f86
commit 21604259a4
2 changed files with 4 additions and 2 deletions

View File

@ -32,7 +32,8 @@ DECLARE
SELECT tablename FROM pg_tables SELECT tablename FROM pg_tables
WHERE tableowner = username AND schemaname = 'public' WHERE tableowner = username AND schemaname = 'public'
AND tablename <> 'notes_semestres' AND tablename <> 'notes_semestres'
AND tablename <> 'notes_form_modalites'; AND tablename <> 'notes_form_modalites'
AND tablename <> 'alembic_version';
BEGIN BEGIN
FOR stmt IN statements LOOP FOR stmt IN statements LOOP
EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;'; EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;';

View File

@ -34,7 +34,8 @@ DECLARE
SELECT tablename FROM pg_tables SELECT tablename FROM pg_tables
WHERE tableowner = username AND schemaname = 'public' WHERE tableowner = username AND schemaname = 'public'
AND tablename <> 'notes_semestres' AND tablename <> 'notes_semestres'
AND tablename <> 'notes_form_modalites'; AND tablename <> 'notes_form_modalites'
AND tablename <> 'alembic_version';
BEGIN BEGIN
FOR stmt IN statements LOOP FOR stmt IN statements LOOP
EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;'; EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;';