Script pour mettre à jour les séquences. Indispensable pour la réplication logique.
#!/bin/sh
cat /dev/null > update_sequence_DB.sql
for sequname in $(psql DB -t -c "select sequence_name as _sequence from information_schema.sequences t where t.sequence_schema='SCHE' order by _sequence asc"); do
echo $sequname
psql DB -t -c "SELECT 'select setval(''${sequname}'','''||last_value||''', true);' from SCHE.${sequname};" >> update_sequence_DB.sql
done