File size: 984 Bytes
92176ae
 
 
 
 
 
 
 
 
 
37ab364
92176ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
begin;

do $$
declare
    tables_to_clear text;
begin
    select string_agg(format('%I.%I', 'public', table_name), ', ' order by table_name)
    into tables_to_clear
    from unnest(array[
        'submission_instructor_feedback',
        'challenge_retry_requests',
        'submission_score_reviews',
        'public_challenge_submissions',
        'round_quota_operations',
        'round_student_quotas',
        'challenge_attempts',
        'submissions',
        'challenge_rounds',
        'course_memberships',
        'course_access_requests',
        'personal_challenge_generations',
        'challenge_generation_events',
        'challenge_generation_runs',
        'challenge_generation_failures',
        'challenge_generation_prompt_rules'
    ]) as listed(table_name)
    where to_regclass(format('%I.%I', 'public', table_name)) is not null;

    if tables_to_clear is not null then
        execute 'truncate table ' || tables_to_clear;
    end if;
end;
$$;

commit;