Skip to content

Commit

Permalink
qf
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Luthe authored and Simon Luthe committed Aug 3, 2024
1 parent 5af6a29 commit 021986a
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions run-migrations.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
#!/bin/bash

# Warten, bis die Datenbank bereit ist
until mysql -h"$DB_HOST" -u"$DB_USER" -p"$DB_PASSWORD" -e "SELECT 1" "$DB_NAME" > /dev/null 2>&1; do
echo "Warte auf Datenbankverbindung..."
sleep 1
max_retries=30
counter=0

echo "Versuche, Verbindung zur Datenbank herzustellen..."
until mysql -h"$DB_HOST" -u"$DB_USER" -p"$DB_PASSWORD" -e "SELECT 1" "$DB_NAME" > /dev/null 2>&1
do
sleep 2
counter=$((counter + 1))
echo "Versuch $counter von $max_retries"
if [ $counter -eq $max_retries ]
then
echo "Konnte keine Verbindung zur Datenbank herstellen nach $max_retries Versuchen."
exit 1
fi
done

echo "Datenbankverbindung hergestellt"

# Führe alle Migrations-Skripte aus
for migration in /app/migrations/*.sql
do
Expand Down

0 comments on commit 021986a

Please sign in to comment.