--- /dev/null
+#!/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;"
+