/
init.sh
executable file
·24 lines (18 loc) · 943 Bytes
/
init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash -x
ROOT_DIR=$(cd $(dirname $0)/..; pwd)
DB_DIR="$ROOT_DIR/db"
BENCH_DIR="$ROOT_DIR/bench"
export MYSQL_PWD=isucon
mysql -uisucon -e "DROP DATABASE IF EXISTS torb; CREATE DATABASE torb;"
mysql -uisucon torb < "$DB_DIR/schema.sql"
if [ ! -f "$DB_DIR/isucon8q-initial-dataset.sql.gz" ]; then
echo "Run the following command beforehand." 1>&2
echo "$ ( cd \"$BENCH_DIR\" && bin/gen-initial-dataset )" 1>&2
exit 1
fi
mysql -uisucon torb -e 'ALTER TABLE reservations DROP KEY event_id_and_sheet_id_idx'
gzip -dc "$DB_DIR/isucon8q-initial-dataset.sql.gz" | mysql -uisucon torb
mysql -uisucon torb -e 'ALTER TABLE reservations ADD KEY event_id_and_sheet_id_idx (event_id, sheet_id)'
mysql -uisucon torb -e'alter table reservations add index user_id(user_id)'
mysql -uisucon torb -e'alter table reservations add index canceled_at(canceled_at)'
mysql -uisucon torb -e'alter table reservations add index reserved_at(reserved_at)'