[PATCH 2/4] ci: test the existence of a patchwork specific table in the database

You-Sheng Yang vicamo at gmail.com
Tue Dec 7 19:49:14 AEDT 2021


Current dev docker image entrypoint script tests only the existence of
the database, but while it might be a blank one, this fails server
starting up because reset_data is not done.

Signed-off-by: You-Sheng Yang <vicamo at gmail.com>
---
 docker-compose-pg.yml      | 4 +++-
 docker-compose.yml         | 4 ++++
 tools/docker/entrypoint.sh | 4 ++--
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/docker-compose-pg.yml b/docker-compose-pg.yml
index a45240e..9b6fdb4 100644
--- a/docker-compose-pg.yml
+++ b/docker-compose-pg.yml
@@ -5,6 +5,8 @@ services:
     volumes:
       - ./tools/docker/db/postdata:/var/lib/postgresql/data
     environment:
+      - POSTGRES_DB=patchwork
+      - POSTGRES_USER=patchwork
       - POSTGRES_PASSWORD=password
 
   web:
@@ -28,5 +30,5 @@ services:
       - DATABASE_HOST=db
       - DATABASE_PORT=5432
       - DATABASE_NAME=patchwork
-      - DATABASE_USER=postgres
+      - DATABASE_USER=patchwork
       - DATABASE_PASS=password
diff --git a/docker-compose.yml b/docker-compose.yml
index 1673823..8526e32 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -5,6 +5,9 @@ services:
     volumes:
       - ./tools/docker/db/data:/var/lib/mysql
     environment:
+      - MYSQL_DATABASE=patchwork
+      - MYSQL_USER=patchwork
+      - MYSQL_PASS=password
       - MYSQL_ROOT_PASSWORD=root
 
   web:
@@ -27,6 +30,7 @@ services:
       # skip DATABASE_TYPE explicitly as mysql should be the default type.
       - DATABASE_HOST=db
       - DATABASE_PORT=3306
+      - DATABASE_NAME=patchwork
       - DATABASE_USER=patchwork
       - DATABASE_PASS=password
       - MYSQL_ROOT_PASSWORD=root
diff --git a/tools/docker/entrypoint.sh b/tools/docker/entrypoint.sh
index d111944..6be90b9 100755
--- a/tools/docker/entrypoint.sh
+++ b/tools/docker/entrypoint.sh
@@ -32,9 +32,9 @@ test_db_connection() {
 
 test_database() {
     if [ ${DATABASE_TYPE} = "postgres" ]; then
-        echo ';' | psql "${psql_args[@]}" "${DATABASE_NAME}" 2> /dev/null
+        echo 'DESCRIBE patchwork_project;' | psql "${psql_args[@]}" "${DATABASE_NAME}" 2> /dev/null
     else
-        echo ';' | mysql "${mysql_args[@]}" "${DATABASE_NAME}" 2> /dev/null
+        echo 'DESCRIBE patchwork_project;' | mysql "${mysql_args[@]}" "${DATABASE_NAME}" 2> /dev/null
     fi
 }
 
-- 
2.32.0



More information about the Patchwork mailing list