File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -173,6 +173,36 @@ jobs:
173173 fi
174174
175175 $COMPOSE -f docker-compose.yml -f docker-compose.dev.yml pull
176+ $COMPOSE -f docker-compose.yml -f docker-compose.dev.yml up -d mysql
177+
178+ DB_ROOT_PASSWORD="$(get_env_value MYSQL_ROOT_PASSWORD)"
179+ DB_NAME="$(get_env_value MYSQL_DATABASE)"
180+
181+ for attempt in $(seq 1 30); do
182+ MYSQL_STATUS="$(sudo docker inspect -f '{{.State.Health.Status}}' ontime-dev-mysql 2>/dev/null || true)"
183+ if [ "$MYSQL_STATUS" = "healthy" ]; then
184+ echo "MySQL container is healthy."
185+ break
186+ fi
187+ echo "Waiting for healthy MySQL status; current status: ${MYSQL_STATUS:-unknown}"
188+ sleep 5
189+ done
190+
191+ MYSQL_STATUS="$(sudo docker inspect -f '{{.State.Health.Status}}' ontime-dev-mysql 2>/dev/null || true)"
192+ [ "$MYSQL_STATUS" = "healthy" ] || fail_deploy "MySQL container did not become healthy."
193+
194+ FAILED_V17_COUNT="$(
195+ sudo docker exec ontime-dev-mysql \
196+ mysql -u root --password="$DB_ROOT_PASSWORD" "$DB_NAME" \
197+ -Nse "SELECT COUNT(*) FROM flyway_schema_history WHERE version = '17' AND success = 0;" 2>/dev/null || echo 0
198+ )"
199+ if [ "$FAILED_V17_COUNT" != "0" ]; then
200+ echo "Repairing failed development Flyway migration V17 before backend startup."
201+ sudo docker exec ontime-dev-mysql \
202+ mysql -u root --password="$DB_ROOT_PASSWORD" "$DB_NAME" \
203+ -e "DROP TABLE IF EXISTS user_refresh_token; DELETE FROM flyway_schema_history WHERE version = '17' AND success = 0;"
204+ fi
205+
176206 $COMPOSE -f docker-compose.yml -f docker-compose.dev.yml up -d --remove-orphans
177207
178208 HEALTHY=false
You can’t perform that action at this time.
0 commit comments