Skip to content

Commit

Permalink
Deal gracefully with missing database columns during postinst.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brendonj committed Dec 12, 2019
1 parent c687daf commit 9fb3812
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9fb3812

Please sign in to comment.