demoreload.sh: add a workaround for NO_ZERO_DATE
authorDenis Ovsienko <denis@ovsienko.info>
Wed, 8 Feb 2017 15:57:15 +0000 (15:57 +0000)
committerDenis Ovsienko <denis@ovsienko.info>
Wed, 8 Feb 2017 15:59:11 +0000 (15:59 +0000)
This allows the demo data to load on MySQL 5.7. It may be necessary to
keep this workaround even after the root cause is properly fixed in
RackTables because the old SQL dump files will continue to have the
zero dates.

demo.racktables.org/demoreload.sh

index 7217cb5..3241957 100755 (executable)
@@ -77,7 +77,8 @@ do_version_19()
                }
        fi
        SQLFILE=`mktemp /tmp/demoreload.XXXXXX`
-       cat "$MYDIR/init-full-$V.sql" > "$SQLFILE"
+       echo 'SET NAMES "utf8", @@SQL_MODE = REPLACE(@@SQL_MODE, "NO_ZERO_DATE", "");' > "$SQLFILE"
+       cat "$MYDIR/init-full-$V.sql" >> "$SQLFILE"
        [ "$DODEMO" = "yes" ] && cat $HOME/RackTables-$V/scripts/init-sample-racks.sql >> "$SQLFILE"
        echo "DROP DATABASE IF EXISTS $DB; CREATE DATABASE $DB CHARACTER SET utf8 COLLATE utf8_general_ci;" | mysql information_schema
        mysql $DB < "$SQLFILE"