Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
do $$
    declare
        r record;
        sql varchar;
    begin
        for r in SELECT
                     tc.table_schema,
                     tc.constraint_name,
                     tc.table_name,
                     kcu.column_name,
                     ccu.table_schema AS foreign_table_schema,
                     ccu.table_name AS foreign_table_name,
                     ccu.column_name AS foreign_column_name
                 FROM
                     information_schema.table_constraints AS tc
                         JOIN information_schema.key_column_usage AS kcu
                              ON tc.constraint_name = kcu.constraint_name
                                  AND tc.table_schema = kcu.table_schema
                         JOIN information_schema.constraint_column_usage AS ccu
                              ON ccu.constraint_name = tc.constraint_name
                                  AND ccu.table_schema = tc.table_schema
                 WHERE tc.constraint_type = 'FOREIGN KEY' and tc.table_schema in (select id from project where archive_initialized = true)
            loop
                sql := 'alter table ' || r.table_schema || '.' || r.table_name ||' drop constraint if exists '|| r.constraint_name;
                -- raise notice '%', sql;
                execute sql;
            end loop;

        for r in select schemaname, tablename, indexname from pg_indexes where schemaname in (select id from project where archive_initialized = true) and indexname like 'index%'
            loop
                sql := 'drop index if exists ' || r.schemaname || '.' || r.indexname;
                execute sql;
                -- raise notice '%', sql;
            end loop;
    end;
$$;

How to Run SQL Fixes

  1. Copy the SQL fixes to a file, let’s assume the file name is upgrade.sql.

  2. Copy the upgrade.sql file to the Postgres container

    Code Block
    docker cp /path_to_file/upgrade.sql am-postgres:/tmp
  3. Run the upgrade.sql file using the Postgres shell, with the default credentials the command would be

    Code Block
    docker exec -e PGPASSWORD=archive-manager am-postgres psql -U archive-manager am_db -f /tmp/upgrade.sql

Configuration:

View file
namePARTICIPANT_MODULE.xml
View file
nameSECURITY_MODULE.xml

...