Files
explorer-monorepo/docs/BLOCKSCOUT_SKIP_MIGRATIONS.md

2.3 KiB

Skip Migrations - Just Start Blockscout

Problem

The Explorer.Release.migrate() function is not available in the eval context, causing the container to restart repeatedly.

Solution

Since the database tables already exist (verified earlier), we can skip migrations and just start Blockscout directly.

Commands

cd /opt/blockscout

# Update docker-compose.yml to just start (no migrations)
python3 << 'PYTHON'
with open('docker-compose.yml', 'r') as f:
    lines = f.readlines()

new_lines = []
i = 0
while i < len(lines):
    line = lines[i]
    # Check if this is a command line
    if 'command:' in line:
        indent = len(line) - len(line.lstrip())
        # Replace with simple start command
        new_lines.append(' ' * indent + 'command: bin/blockscout start\n')
        i += 1
        # Skip the list items (- sh, -c, etc.)
        while i < len(lines) and lines[i].strip().startswith('-'):
            i += 1
        continue
    new_lines.append(line)
    i += 1

with open('docker-compose.yml', 'w') as f:
    f.writelines(new_lines)

print("✅ Updated to just start (no migrations)")
PYTHON

# Verify
grep -A 1 "command:" docker-compose.yml

# Restart
docker-compose down blockscout
docker-compose up -d blockscout

# Check status
sleep 30
docker ps | grep blockscout
docker logs blockscout 2>&1 | tail -30

Why This Works

  1. Tables already exist: We verified that migrations_status, blocks, and transactions tables exist
  2. Migrations were run: The tables wouldn't exist if migrations hadn't been run previously
  3. Release module unavailable: The Explorer.Release module is only available in certain contexts, not in regular eval

Alternative: If Migrations Are Needed Later

If you need to run migrations in the future, you can:

  1. Use a one-off container:
docker run --rm \
  --network host \
  -e DATABASE_URL=postgresql://blockscout:blockscout@localhost:5432/blockscout \
  blockscout/blockscout:latest \
  bin/blockscout eval "Application.ensure_all_started(:explorer); Explorer.Release.migrate()"
  1. Or connect to the running container and run migrations manually:
docker exec -it blockscout bin/blockscout remote
# Then in the remote console:
Explorer.Release.migrate()

But for now, since tables exist, just starting Blockscout should work.