2020-04-14 11:57:21 +02:00
#!/bin/bash
2020-05-14 23:43:02 +02:00
DBHOST = "127.0.0.1"
DBUSER_MONARC = "sqlmonarcuser"
2020-04-14 11:57:21 +02:00
DBPASSWORD_MONARC = "sqlmonarcuser"
2020-05-14 23:43:02 +02:00
# Comment/Uncomment and modify the following line to run tests from your host machine:
CONNECTION_OPTIONS = "--ssl-key=~/web/monarc/MonarcAppFO/vagrant/.vagrant/machines/default/virtualbox/private_key"
2020-06-30 21:18:06 +02:00
#CONNECTION_OPTIONS=""
2020-04-14 11:57:21 +02:00
2020-05-14 23:43:02 +02:00
mysql -h $DBHOST -u $DBUSER_MONARC -p$DBPASSWORD_MONARC $CONNECTION_OPTIONS -e "CREATE DATABASE IF NOT EXISTS monarc_cli_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" > /dev/null
2020-04-14 11:57:21 +02:00
# Check if the database is already exist we don't need to create the structure and import the data.
2020-06-30 21:18:06 +02:00
if ! mysql -h $DBHOST -u $DBUSER_MONARC -p$DBPASSWORD_MONARC $CONNECTION_OPTIONS -e "use monarc_common_test" ; then
2020-05-14 23:43:02 +02:00
mysql -h $DBHOST -u $DBUSER_MONARC -p$DBPASSWORD_MONARC $CONNECTION_OPTIONS -e "CREATE DATABASE monarc_common_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" > /dev/null
mysql -h $DBHOST -u $DBUSER_MONARC -p$DBPASSWORD_MONARC $CONNECTION_OPTIONS monarc_common_test < db-bootstrap/monarc_structure.sql > /dev/null
mysql -h $DBHOST -u $DBUSER_MONARC -p$DBPASSWORD_MONARC $CONNECTION_OPTIONS monarc_common_test < db-bootstrap/monarc_data.sql > /dev/null
2020-04-14 11:57:21 +02:00
fi
2020-06-30 21:18:06 +02:00
if [ [ ! $( mysql -h $DBHOST -u $DBUSER_MONARC -p$DBPASSWORD_MONARC $CONNECTION_OPTIONS -e 'SHOW TABLES LIKE "phinxlog"' monarc_common_test) ] ]
then
php bin/phinx migrate -c tests/migrations/phinx_core.php
fi
if [ [ ! $( mysql -h $DBHOST -u $DBUSER_MONARC -p$DBPASSWORD_MONARC $CONNECTION_OPTIONS -e 'SHOW TABLES LIKE "phinxlog"' monarc_cli_test) ] ]
then
php bin/phinx migrate -c tests/migrations/phinx_frontoffice.php
fi