#!/bin/sh

set -xe

export DW_TEST=1

mysql -u root -e "\
    CREATE USER IF NOT EXISTS testuser@localhost IDENTIFIED BY ''; \
    CREATE DATABASE IF NOT EXISTS test_master; \
    CREATE DATABASE IF NOT EXISTS test_c01; \
    CREATE DATABASE IF NOT EXISTS test_c02; \
    CREATE DATABASE IF NOT EXISTS test_schwartz; \
    GRANT ALL ON test_master.* TO testuser@localhost; \
    GRANT ALL ON test_c01.* TO testuser@localhost; \
    GRANT ALL ON test_c02.* TO testuser@localhost; \
    GRANT ALL ON test_schwartz.* TO testuser@localhost; \
    FLUSH PRIVILEGES;"

$LJHOME/bin/upgrading/update-db.pl -r --innodb
$LJHOME/bin/upgrading/update-db.pl -r --innodb # at least for now we have to run this twice
$LJHOME/bin/upgrading/update-db.pl -r --cluster=all --innodb
$LJHOME/bin/upgrading/update-db.pl -r --cluster=all --innodb # this one too
$LJHOME/bin/upgrading/update-db.pl -p

$LJHOME/bin/upgrading/texttool.pl load
