From 88904fcb53856f9342073f73802248419fc4b338 Mon Sep 17 00:00:00 2001 From: slawk0 Date: Wed, 18 Sep 2024 20:48:18 +0200 Subject: [PATCH] fixed app starting before db, added creation of contact db --- backend/db.js | 9 +++++++++ docker-compose.yaml | 3 ++- frontend/routes/chat.html | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/db.js b/backend/db.js index 1273a32..6039e2f 100644 --- a/backend/db.js +++ b/backend/db.js @@ -43,6 +43,15 @@ async function createTables() { ) `); + // Create contacts table + await db.query(` + CREATE TABLE IF NOT EXISTS contacts ( + username TEXT NOT NULL, + contact TEXT NOT NULL, + status TEXT NOT NULL + ) + `); + console.log('Tables created successfully'); } catch (err) { console.error('Error creating tables:', err); diff --git a/docker-compose.yaml b/docker-compose.yaml index fd2ec14..27d3448 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -34,7 +34,8 @@ services: ports: - ${APP_PORT}:${APP_PORT} depends_on: - - db + db: + condition: service_healthy volumes: db-data: diff --git a/frontend/routes/chat.html b/frontend/routes/chat.html index 8e499db..8bfbe49 100644 --- a/frontend/routes/chat.html +++ b/frontend/routes/chat.html @@ -18,6 +18,7 @@
+