File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -155,6 +155,7 @@ def DATABASE_URL(self) -> str:
155155 f"postgresql+psycopg2://{ self .DATABASE_USER } :"
156156 f"{ self .DATABASE_PASSWORD } @{ self .DATABASE_HOST } :"
157157 f"{ self .DATABASE_PORT } /{ self .DATABASE_NAME } "
158+ f"?connect_timeout=5"
158159 )
159160
160161 @property
Original file line number Diff line number Diff line change 11#! /bin/sh
22set -e
33
4+ # Wait for database to be reachable before running migrations
5+ MAX_RETRIES=${DB_WAIT_RETRIES:- 10}
6+ RETRY=0
7+ until python -c " import socket; s=socket.create_connection(('${DATABASE_HOST:- localhost} ', ${DATABASE_PORT:- 5432} ), timeout=3); s.close()" 2> /dev/null; do
8+ RETRY=$(( RETRY + 1 ))
9+ if [ " $RETRY " -ge " $MAX_RETRIES " ]; then
10+ echo " ERROR: Database not reachable after $MAX_RETRIES attempts. Exiting."
11+ exit 1
12+ fi
13+ echo " Waiting for database ($RETRY /$MAX_RETRIES )..."
14+ sleep 3
15+ done
16+ echo " Database is reachable."
17+
418echo " Running Alembic migrations..."
519alembic upgrade head
620echo " Migrations complete."
You can’t perform that action at this time.
0 commit comments