# Working Blockscout Fix - Final Version ## Issues Found 1. `bin/blockscout migrate` doesn't exist - must use `eval "Explorer.Release.migrate()"` 2. Container name conflict - old container must be removed first 3. Tables already exist - migrations were run before ## Working Commands (Run in VMID 5000) ### Step 1: Remove Old Container ```bash # Remove the old stopped container docker rm -f blockscout 2>/dev/null || true docker rm -f 951bf74faf67 2>/dev/null || true # Verify it's gone docker ps -a | grep blockscout ``` ### Step 2: Run Migrations (if needed - tables already exist) Since tables already exist, migrations may not be needed, but we can verify: ```bash # Check if migrations_status has entries docker exec blockscout-postgres psql -U blockscout -d blockscout -c " SELECT COUNT(*) as migration_count FROM migrations_status; " ``` ### Step 3: Fix docker-compose.yml ```bash cd /opt/blockscout # Check current command grep -A 1 "command:" docker-compose.yml # Use Python to update (handles quotes properly) python3 << 'PYTHON' import re with open('docker-compose.yml', 'r') as f: content = f.read() # Replace command line - use eval for migrations old_pattern = r'command:\s*.*blockscout start' new_command = 'command: sh -c "bin/blockscout eval \"Explorer.Release.migrate()\" && bin/blockscout start"' content = re.sub(old_pattern, new_command, content) # Also handle /app/bin/blockscout start content = re.sub(r'command:\s*.*/app/bin/blockscout start', new_command, content) with open('docker-compose.yml', 'w') as f: f.write(content) print("✅ Updated docker-compose.yml") PYTHON ``` ### Step 4: Start Blockscout ```bash cd /opt/blockscout docker-compose up -d blockscout # Wait and check sleep 30 docker ps | grep blockscout docker logs blockscout 2>&1 | tail -30 ``` ## Alternative: Skip Migrations Since Tables Exist If tables already exist, we can just start Blockscout without running migrations: ```bash cd /opt/blockscout # Remove old container docker rm -f blockscout 2>/dev/null || true # Update docker-compose.yml to just start (no migrations) python3 << 'PYTHON' import re with open('docker-compose.yml', 'r') as f: content = f.read() # Just use start command content = re.sub(r'command:\s*.*blockscout start', 'command: bin/blockscout start', content) content = re.sub(r'command:\s*.*/app/bin/blockscout start', 'command: bin/blockscout start', content) with open('docker-compose.yml', 'w') as f: f.write(content) print("✅ Updated to just start") PYTHON # Start docker-compose up -d blockscout sleep 30 docker ps | grep blockscout docker logs blockscout 2>&1 | tail -30 ```