\set script_file `date +%Y%m%d%H%M%S` .sql
\t
\o :script_file
select
    'alter sequence incident_id_seq restart ' || max(id) + 1 || ';'
from
    incident;
\o
\t
\i :script_file
