фикс импорта бд
This commit is contained in:
+16
-3
@@ -37,15 +37,28 @@ EOF
|
||||
log() { printf '[db-import] %s\n' "$*"; }
|
||||
die() { printf 'ERROR: %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
require_running_db() {
|
||||
require_ready_db() {
|
||||
if ! docker compose ps --status running --services 2>/dev/null | grep -qx 'ac-database'; then
|
||||
die "ac-database is not running. Start it with: docker compose up -d ac-database"
|
||||
fi
|
||||
|
||||
log "waiting for MySQL to be ready..."
|
||||
local attempts=0
|
||||
until docker compose exec -T ac-database bash -lc \
|
||||
"mysql -h 127.0.0.1 -uroot -p\"\$MYSQL_ROOT_PASSWORD\" -e 'SELECT 1;'" \
|
||||
>/dev/null 2>&1; do
|
||||
attempts=$((attempts + 1))
|
||||
if [[ $attempts -ge 30 ]]; then
|
||||
die "MySQL did not become ready in time. Check: docker logs ac-database"
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
log "MySQL is ready"
|
||||
}
|
||||
|
||||
mysql_exec() {
|
||||
docker compose exec -T ac-database bash -lc \
|
||||
"mysql -uroot -p\"\$MYSQL_ROOT_PASSWORD\""
|
||||
"mysql -h 127.0.0.1 -uroot -p\"\$MYSQL_ROOT_PASSWORD\""
|
||||
}
|
||||
|
||||
# ── argument parsing ──────────────────────────────────────────────────────────
|
||||
@@ -89,7 +102,7 @@ fi
|
||||
|
||||
# ── import ────────────────────────────────────────────────────────────────────
|
||||
|
||||
require_running_db
|
||||
require_ready_db
|
||||
|
||||
log "restoring $DUMP_FILE into ac-database..."
|
||||
log "this may take several minutes..."
|
||||
|
||||
Reference in New Issue
Block a user