diff --git a/test-and-deploy.yml b/test-and-deploy.yml
index c0d0f28b3cf3a6ec1e00c6fcebfc475bd8cecf3b..8fcdd3deb444714f7302b1b0f60942a724abf297 100644
--- a/test-and-deploy.yml
+++ b/test-and-deploy.yml
@@ -55,6 +55,7 @@ stages:
   variables:
     GIT_STRATEGY: none
   script: |
+    docker container ls --all -q -f name=^${COMPOSE_PROJECT_NAME}_mariadb_1$
     DBREQUIRED="no"
     if [[ "$CI_COMMIT_REF_NAME" == "master" ]]; then
       DBREQUIRED="yes"
@@ -68,7 +69,7 @@ stages:
         DBREQUIRED="yes"
       else
         TABLES=$(docker exec ${COMPOSE_PROJECT_NAME}_mariadb_1 mysql -u drupal --password=drupal -e "show tables;" drupal 2>/dev/null|grep users)
-        if [[ ! -n ${ID} ]]; then
+        if [[ ! -n ${TABLES} ]]; then
           DBREQUIRED="yes"
         fi
       fi