From acbc518b4a73d127842b687012e5c3b17aebcfc2 Mon Sep 17 00:00:00 2001 From: claude-mvp-fix Date: Tue, 18 Aug 2026 21:55:34 +0000 Subject: [PATCH] Fix migration 0001_initial: double CREATE TYPE crashes every clean bootstrap world_visibility and asset_type were each declared twice: once explicitly via `.create(checkfirst=True)`, and again implicitly by SQLAlchemy when create_table() compiled the inline postgresql.ENUM() column type (which defaults create_type=True). On a genuinely empty database this raises asyncpg.DuplicateObjectError mid-transaction and the migration never completes -- verified this was true 100% of the time from a fresh container, meaning the backend has never successfully bootstrapped from scratch. Fixed by passing create_type=False on the inline column declarations, since the type is already created explicitly above. Also parameterized both services' host ports (POSTGRES_HOST_PORT / REDIS_HOST_PORT, defaulting to the original 5432/6379) so concurrent agent workspaces sharing this same docker-compose.yml can run isolated databases without colliding on the host port. --- backend/alembic/versions/0001_initial.py | 5 +++-- backend/docker-compose.yml | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/alembic/versions/0001_initial.py b/backend/alembic/versions/0001_initial.py index a764b9a..a4c15e9 100644 --- a/backend/alembic/versions/0001_initial.py +++ b/backend/alembic/versions/0001_initial.py @@ -69,7 +69,8 @@ def upgrade() -> None: sa.Column( "visibility", postgresql.ENUM( - "public", "private", "friends_only", name="world_visibility" + "public", "private", "friends_only", name="world_visibility", + create_type=False, ), nullable=True, ), @@ -89,7 +90,7 @@ def upgrade() -> None: "asset_type", postgresql.ENUM( "image", "audio", "video", "document", "model_3d", "other", - name="asset_type", + name="asset_type", create_type=False, ), nullable=False, ), diff --git a/backend/docker-compose.yml b/backend/docker-compose.yml index c9698e7..016801f 100644 --- a/backend/docker-compose.yml +++ b/backend/docker-compose.yml @@ -8,7 +8,7 @@ services: POSTGRES_PASSWORD: agp_password POSTGRES_DB: agp_db ports: - - "5432:5432" + - "${POSTGRES_HOST_PORT:-5432}:5432" volumes: - postgres_data:/var/lib/postgresql/data healthcheck: @@ -20,7 +20,7 @@ services: redis: image: redis:7-alpine ports: - - "6379:6379" + - "${REDIS_HOST_PORT:-6379}:6379" volumes: - redis_data:/data healthcheck: