From 22d00a3754e0238d1e5b4f108b2b9680c5169d54 Mon Sep 17 00:00:00 2001 From: Peter Schiffer <3899107+pschiffe@users.noreply.github.com> Date: Mon, 16 Jan 2023 14:10:39 +0100 Subject: [PATCH] Include automatic db schema migration to version 4.7 https://doc.powerdns.com/authoritative/upgrading.html#to-4-7-0-or-master fixes #97 --- pdns/docker-entrypoint.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pdns/docker-entrypoint.sh b/pdns/docker-entrypoint.sh index 45a3848..8621c87 100755 --- a/pdns/docker-entrypoint.sh +++ b/pdns/docker-entrypoint.sh @@ -53,6 +53,14 @@ if [ "$MYSQL_NUM_TABLE" -eq 0 ]; then $MYSQL_COMMAND -D "$PDNS_gmysql_dbname" < /usr/share/doc/pdns/schema.mysql.sql fi +# SQL migration to version 4.7 +MYSQL_CHECK_IF_47="SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = '${PDNS_gmysql_dbname}' AND table_name = 'domains' AND column_name = 'options';" +MYSQL_NUM_TABLE=$($MYSQL_COMMAND --batch --skip-column-names -e "$MYSQL_CHECK_IF_47") +if [ "$MYSQL_NUM_TABLE" -eq 0 ]; then + echo 'Migrating MySQL schema to version 4.7...' + $MYSQL_COMMAND -D "$PDNS_gmysql_dbname" < /usr/share/doc/pdns/4.3.0_to_4.7.0_schema.mysql.sql +fi + if [ "${PDNS_superslave:-no}" == "yes" ]; then # Configure supermasters if needed if [ "${SUPERMASTER_IPS:-}" ]; then