aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaios <naios-dev@live.de>2015-10-05 23:19:07 +0200
committerNaios <naios-dev@live.de>2015-10-05 23:29:34 +0200
commit4dd6070c795fa7b34a38af0bd8d19d55bbc62959 (patch)
tree8b5bd55fd4ca86bf707f75ea1cf4510fecff8884
parent126b57acc665a918d3c72749cab4535878594591 (diff)
Travis: Add check for update entries not listed in base dumps.
* Will mark the travis build as failed when the database updater is broken.
-rw-r--r--.travis.yml5
-rw-r--r--contrib/check_updates.sh44
2 files changed, 48 insertions, 1 deletions
diff --git a/.travis.yml b/.travis.yml
index be3713b928b..17d703a2f8e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,12 +19,15 @@ install:
- mkdir bin
- cd bin
- cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=1 -DSCRIPTS=1 -DSERVERS=1 -DNOJEM=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror"
+ - cd ..
+ - sudo chmod +x contrib/check_updates.sh
script:
- - cd ..
- mysql -uroot < sql/create/create_mysql.sql
- mysql -utrinity -ptrinity auth < sql/base/auth_database.sql
+ - ./contrib/check_updates.sh auth auth
- mysql -utrinity -ptrinity characters < sql/base/characters_database.sql
+ - ./contrib/check_updates.sh characters characters
- mysql -utrinity -ptrinity world < sql/base/dev/world_database.sql
- cat sql/updates/world/*.sql | mysql -utrinity -ptrinity world
- mysql -uroot < sql/create/drop_mysql.sql
diff --git a/contrib/check_updates.sh b/contrib/check_updates.sh
new file mode 100644
index 00000000000..97aa3dff7a8
--- /dev/null
+++ b/contrib/check_updates.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+name=$1
+database=$2
+
+echo "Database Updater check script:"
+echo " Checking database '${name}' for missing filenames in tables..."
+echo
+
+# Select all entries which are in the updates table
+entries=$(mysql -uroot ${database} -e "SELECT name FROM updates" | grep ".sql")
+
+cd sql/updates/${name}
+
+error=0
+updates=0
+
+for file in *.sql
+do
+ # Check if the given update is in the `updates` table.
+ if echo "${entries}" | grep -q "^${file}"; then
+ # File is ok
+ updates=$((updates+1))
+ else
+ # The update isn't listed in the updates table of the given database.
+ echo "- \"sql/updates/${file}\" is missing in table '${name}'.'updates'"
+ error=1
+ fi
+done
+
+if [ ${error} -ne 0 ]
+ then
+ echo
+ echo "Fatal error:"
+ echo " The Database Updater is broken for database '${name}"
+ echo " due to applied update which are missing in the '${name}'.'updates' table."
+ echo
+ echo "How to fix:"
+ echo " Insert the missing names of sql updates which were applied already to"
+ echo " the 'updates' table of the '${name}' base dump ('sql/base/${name}_database.sql')."
+ exit 1
+ else
+ echo " Everything is ok, checked ${updates} updates."
+ exit 0
+fi