migration script to new database schema
authorJiří Filipovič <fila@ics.muni.cz>
Tue, 28 Aug 2012 09:37:01 +0000 (09:37 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Tue, 28 Aug 2012 09:37:01 +0000 (09:37 +0000)
org.glite.lb.server/config/glite-lb-migrate_db2version40 [new file with mode: 0755]

diff --git a/org.glite.lb.server/config/glite-lb-migrate_db2version40 b/org.glite.lb.server/config/glite-lb-migrate_db2version40
new file mode 100755 (executable)
index 0000000..95cbaa9
--- /dev/null
@@ -0,0 +1,77 @@
+#!/bin/bash
+
+# This script is intendent to be used to extend bkserver database to 
+# to be able to hold both bkserver and lbproxy jobs.
+# The operation should be non-destructive, i.e. all data should persist
+# and continue to be fully usable.
+usage() {
+cat <<EOF
+NAME:
+       glite-lb-migrate_db2version40
+               script for migrating older LB server or proxy databases
+               to new schema required for storing job connections 
+USAGE:
+       glite-lb-migrate_db2version40 -s|-p [-d db_name]
+
+               -s              migrate old server DB to new version
+               -p              migrate old proxy DB to new version
+               -d db_name      non-default database name
+EOF
+
+}
+
+SERVER=""
+PROXY=""
+
+while getopts "spd:h" OPTION 
+do
+    case "$OPTION" in 
+    "s") SERVER=1
+    ;;
+
+    "p") PROXY=1
+    ;;
+
+    "d") DB_NAME=$OPTARG
+    ;;
+
+    "h") 
+       usage;
+       exit;
+    ;;
+
+    esac
+done
+
+if [ -z "$SERVER" -a -z "$PROXY" ]; then
+       usage;
+       exit;
+fi
+
+if [ "$SERVER" -a "$PROXY" ]; then
+       usage;
+       exit;
+fi
+
+
+# default DB name (for server or proxy, overriden by -d option)
+if [ -z "$DB_NAME" ]; then
+       if [ "$SERVER" ]; then
+               DB_NAME="lbserver20"
+       else
+               DB_NAME="lbproxy"
+       fi
+fi
+
+
+# job connections table
+mysql -u lbserver $DB_NAME -e "\
+create table job_connections (\
+        jobid_from      char(32)        binary not null,\
+        jobid_to        char(32)        binary not null,\
+        jobtype         int             not null,\
+        connection      int             not null,\
+        primary key (jobid_from, jobid_to)\
+) engine=innodb;"
+