Skip to content

Bug: Docker compose has no database migration step — SLM tables missing on first boot #1893

@mrveiss

Description

@mrveiss

Problem

docker-compose.yml includes PostgreSQL with init-databases.sql that creates empty databases (autobot_slm, slm_users), but Alembic migrations never run. On first boot, SLM health checks pass (daemon is up) but API calls fail with 500 errors because tables don't exist.

Impact

High — SLM backend is non-functional after docker compose up until manual alembic upgrade head is run inside the container.

Expected Fix

Add migration step via entrypoint script or init container:

Option A — Entrypoint wrapper for SLM:

#!/bin/bash
# wait-for-db-and-migrate.sh
python -c "import asyncio; from database.db_service import DatabaseService; asyncio.run(DatabaseService().initialize())"
alembic upgrade head
exec "$@"

Option B — Init container:

autobot-slm-migrate:
  build: { context: ., dockerfile: docker/slm/Dockerfile }
  command: alembic upgrade head
  depends_on:
    autobot-postgres: { condition: service_healthy }

Discovered During

Working on #1809 Docker containerization.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions