summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorYehonal <yehonal.azeroth@gmail.com>2016-08-25 19:49:32 +0200
committerYehonal <yehonal.azeroth@gmail.com>2016-08-25 19:49:32 +0200
commit7cab63179ee7eaf9e5982973958b7fb66170ffa9 (patch)
tree30a68f32a7cdfd47ce63dc0915f895184ba210e1 /bin
parentcb19ac25b78c883b06ac642e4b58a67ddb6d54f9 (diff)
implemented pending workflow for sql and PR
Diffstat (limited to 'bin')
-rwxr-xr-xbin/db_pendings/import.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/bin/db_pendings/import.sh b/bin/db_pendings/import.sh
new file mode 100755
index 0000000000..95bce984cc
--- /dev/null
+++ b/bin/db_pendings/import.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+source "$CURRENT_PATH/../bash_shared/includes.sh"
+
+
+
+UPDATES_PATH="$AC_PATH_ROOT/data/sql/updates/"
+
+function import() {
+ folder="db_"$1
+ pendingPath="$AC_PATH_ROOT/data/sql/updates/pending_$folder"
+ updPath="$UPDATES_PATH/$folder"
+
+ latestUpd=`ls $updPath/ -1 | tail -n 1`
+
+ if [ -z $latestUpd ]; then
+ echo "FIRST UPDATE FILE MISSING!! DID YOU ARCHIVED IT?";
+ exit;
+ fi
+
+ dateToday=`date +%Y_%m_%d`
+ counter=0
+
+ dateLast=$latestUpd
+ tmp=${dateLast#*_*_*_}
+ oldCnt=${tmp%.sql}
+ oldDate=${dateLast%_$tmp}
+
+ if [ "$oldDate" = "$dateToday" ]; then
+ ((counter=$oldCnt+1))
+ fi;
+
+ for entry in "$pendingPath"/*.sql
+ do
+ if [[ -e $entry ]]; then
+ updHeader="ALTER TABLE db_version CHANGE COLUMN "$latestUpd" "$dateToday"_"$counter" bit;";
+ cnt=$(printf -v counter "%02d" $counter ; echo $counter)
+ newFile="$updPath/"$dateToday"_"$cnt".sql"
+ echo "$updHeader" > "$newFile"
+ echo "--" >> "$newFile"
+ echo "--" >> "$newFile"
+ cat $entry >> "$newFile"
+ rm $entry
+ ((counter+=1))
+ fi
+ done
+
+}
+
+import "world"
+import "characters"
+import "auth"