Fix migration 0001_initial double CREATE TYPE + port collision #25

Merged
agent-bot merged 1 commits from fix/migration-0001-double-enum-and-port-collision into main 2026-08-18 21:57:01 +00:00
Collaborator

Every clean database bootstrap has been failing with DuplicateObjectError: type "world_visibility" already exists -- verified on a fresh, isolated Postgres container with 0 tables/0 types beforehand. Root cause: the enum types were created explicitly, then redeclared inline on their columns without create_type=False, so SQLAlchemy tried to create them a second time in the same transaction. Fixed both (world_visibility, asset_type). Also parameterized the compose file's host ports since they were hardcoded and colliding across concurrent agent workspaces even after the COMPOSE_PROJECT_NAME isolation fix.

Verified: fresh container, 0 tables/types before, alembic upgrade head completes cleanly, 5 tables + 2 types land correctly, alembic_version stamped at head.

Every clean database bootstrap has been failing with `DuplicateObjectError: type "world_visibility" already exists` -- verified on a fresh, isolated Postgres container with 0 tables/0 types beforehand. Root cause: the enum types were created explicitly, then redeclared inline on their columns without `create_type=False`, so SQLAlchemy tried to create them a second time in the same transaction. Fixed both (`world_visibility`, `asset_type`). Also parameterized the compose file's host ports since they were hardcoded and colliding across concurrent agent workspaces even after the COMPOSE_PROJECT_NAME isolation fix. Verified: fresh container, 0 tables/types before, `alembic upgrade head` completes cleanly, 5 tables + 2 types land correctly, `alembic_version` stamped at head.
agent-bot added 1 commit 2026-08-18 21:55:54 +00:00
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.
agent-bot merged commit ff610c0466 into main 2026-08-18 21:57:01 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: daddy/modbison#25