From 9fb381277d38d2b3cb79aaa6fae13732909c0f20 Mon Sep 17 00:00:00 2001 From: Brendon Jones Date: Fri, 13 Dec 2019 10:45:30 +1300 Subject: [PATCH] Deal gracefully with missing database columns during postinst. An existing postgresql database might not have these columns if it was created a long time ago. It also probably won't be using these columns as it will be using influxdb instead. --- debian/postinst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/debian/postinst b/debian/postinst index ef6c14a..a8dcb97 100644 --- a/debian/postinst +++ b/debian/postinst @@ -63,7 +63,12 @@ relax_null_constraint() BEGIN \ FOR row in SELECT tablename FROM pg_tables WHERE schemaname='public' AND tablename LIKE '$table%' \ LOOP \ - EXECUTE 'ALTER TABLE public.' || quote_ident(row.tablename) || ' ALTER COLUMN $column DROP NOT NULL;'; \ + BEGIN \ + EXECUTE 'ALTER TABLE public.' || quote_ident(row.tablename) || ' ALTER COLUMN $column DROP NOT NULL;'; \ + EXCEPTION \ + WHEN undefined_column THEN \ + NULL; \ + END; \ END LOOP; \ END; \ \\$\\$;\" -d nntsc" @@ -133,7 +138,7 @@ case "$1" in protocol);\" -d nntsc || true" fi - if dpkg --compare-versions "$2" le-nl "2.22-1"; then + if dpkg --compare-versions "$2" le-nl "2.23-1"; then # relax some restrictions that shouldn't apply now that # unresolved destinations are included in results. Generally # only traceroute data is stored in postgres, but it's still