#!/usr/bin/env bash
set -e

#################################################################
#
# This script should only be executed within the leader instance!
#
#################################################################

. /opt/elasticbeanstalk/support/envvars

cd $(cd $(dirname $0); echo $PWD)
cd ..

set -xe

echo "Application update database start..."

#
# Ensure that database is up2date before application is deployed
#
php bin/console doctrine:database:create --if-not-exists --no-interaction
php bin/console doctrine:migrations:migrate --allow-no-migration --no-interaction

echo "Application update database done."
