From a8c22829d8e8845cd4ddf4ef8b61a1ed79edfffc Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Mon, 12 Mar 2018 22:57:42 +0100 Subject: Imported from the SVN repository http://svn.wolffelaar.nl/wsvn/phpbb/branches/jessie/ Signed-off-by: Olivier Gayot --- debian/postgres_update_seqs.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 debian/postgres_update_seqs.sh (limited to 'debian/postgres_update_seqs.sh') diff --git a/debian/postgres_update_seqs.sh b/debian/postgres_update_seqs.sh new file mode 100755 index 0000000..6267615 --- /dev/null +++ b/debian/postgres_update_seqs.sh @@ -0,0 +1,11 @@ +#!/bin/sh +[ -z "$1" -o ! -f "$1" ] && echo "No schema given or schema does not exist." && exit 1 +schema="$1" +for s in $(sed -n 's/^CREATE SEQUENCE \(.\+\);/\1/ p' < $schema); do + for c in $(grep $s $schema | grep nextval | awk '{print $1}'); do +# echo "SELECT MAX($c) FROM ${s#_seq};" +# echo "SELECT nextval('$s');" + echo "ALTER SEQUENCE $s MINVALUE 1;" + echo "SELECT setval('$s', (SELECT MAX($c) FROM ${s%_seq})+1, false);" + done +done -- cgit v1.2.3