Compare commits

..

1 Commits

Author SHA1 Message Date
claude-mvp-fix acbc518b4a 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.
2026-08-18 21:55:34 +00:00
3 changed files with 5 additions and 36 deletions
+3 -2
View File
@@ -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,
),
-32
View File
@@ -3,10 +3,6 @@ from sqlalchemy.dialects.postgresql import ENUM
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
import enum
import json
from typing import Optional, List
from pydantic import BaseModel as PydanticBaseModel
from app.database import Base
@@ -42,31 +38,3 @@ class Asset(Base):
owner = relationship("User", back_populates="assets")
world = relationship("World", back_populates="assets")
class GLTFMetadata(PydanticBaseModel):
"""Pydantic schema for glTF asset metadata."""
mesh_count: Optional[int] = None
vertex_count: Optional[int] = None
has_animation: bool = False
texture_refs: Optional[List[str]] = None
tags: Optional[List[str]] = None
model_config = {"from_attributes": True}
def parse_metadata_json(metadata_text: Optional[str]) -> dict:
"""Parse the metadata_json text field into a dict, handling None gracefully."""
if not metadata_text:
return {}
try:
return json.loads(metadata_text)
except (json.JSONDecodeError, TypeError):
return {}
def serialize_metadata(metadata: dict) -> Optional[str]:
"""Serialize metadata dict to JSON string for storage."""
if not metadata:
return None
return json.dumps(metadata)
+2 -2
View File
@@ -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: