Skip to content

Commit ba22fbb

Browse files
committed
Init EB DB using migrations instead of schema:create
Prior to this change, the EB DB schema in devconf would deviate from the migrations (prod) database, because new changes would be applied automatically via schema:create instead of applying the migrations. This change ensures the EB DB is bootstrapped using the database migrations to match prod. Resolves: OpenConext/OpenConext-engineblock#1861
1 parent 86f5dcd commit ba22fbb

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

core/scripts/init.sh

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ set -e
1212

1313
# Bootstrapping engineblock means initialising the database
1414
printf "\n"
15-
echo -e "${ORANGE}Bring up the engineblock container to bootstrap the database${NOCOLOR}"
15+
echo -e "${ORANGE}Bring up the engineblock Production container to bootstrap the database using the Production container's migrations${NOCOLOR}"
16+
echo "Comment the two lines below to run the migrations from your own running engine container (ensure your EB is running)."
1617
echo
1718

1819
# Wait for engine to come up; not health yet because we might nee to initialialize db
@@ -22,14 +23,10 @@ docker compose exec engine timeout 300 bash -c 'while [[ "$(curl -k -s -o /dev/n
2223
echo
2324
echo -e "${ORANGE}Initializing EB database$NOCOLOR ${VINKJE}"
2425
echo
25-
echo "Checking if the database is already present"
26-
if ! docker compose exec engine /var/www/html/bin/console doctrine:schema:validate -q --skip-mapping --env=prod > /dev/null
27-
then
28-
echo creating the database schema
29-
cmd='docker compose exec engine /var/www/html/bin/console doctrine:schema:update --force -q'
30-
#echo "Executing: ${cmd}"
31-
${cmd}
32-
fi
26+
echo "Running database migrations"
27+
cmd='docker compose exec engine /var/www/html/bin/console doctrine:migrations:migrate --no-interaction'
28+
${cmd}
29+
3330
echo "Clearing the cache"
3431
docker compose exec engine /var/www/html/bin/console cache:clear -n --env=prod
3532
docker compose exec engine chown -R www-data:www-data /var/www/html/var/cache/

0 commit comments

Comments
 (0)