2017-05-01 12:31:44 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Copies over the ddl files
|
|
|
|
|
2017-05-19 05:54:28 +09:00
|
|
|
# Get parent directory of this file.
|
|
|
|
# e.g. /Users/me/workspace/WhereHows/docker/mysql
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
2017-05-01 12:31:44 -04:00
|
|
|
|
|
|
|
rm -rf *_DDL
|
2017-05-19 05:54:28 +09:00
|
|
|
rm -f bin/create_all_tables_wrapper.sql
|
2017-05-01 12:31:44 -04:00
|
|
|
|
2017-05-19 05:54:28 +09:00
|
|
|
DDL_DIR=${SCRIPT_DIR}/../../data-model/DDL
|
|
|
|
mkdir -p bin
|
2017-05-01 12:31:44 -04:00
|
|
|
cp $DDL_DIR/create_all_tables_wrapper.sql bin
|
|
|
|
cp -r $DDL_DIR/*_DDL .
|
|
|
|
|
|
|
|
# Unfortunately these scripts may be executed multiple times.
|
|
|
|
# The data directory is mounted as a volume, meaning that these scripts could run twice for the
|
|
|
|
# same directory. Change schema to just create tables if they do not already exist.
|
|
|
|
sed -i "" -e "s/CREATE TABLE/CREATE TABLE IF NOT EXISTS/g" *_DDL/*
|
|
|
|
|
|
|
|
# In some places we just doubled up on IF NOT EXISTS
|
|
|
|
sed -i "" -e "s/IF NOT EXISTS IF NOT EXISTS/IF NOT EXISTS/g" *_DDL/*
|
|
|
|
|