lukemcqueen/hermes-cortex/alembic-enum-double-create
Claude Code and agent skill by lukemcqueen/hermes-cortex
- community
Checking that the SKILL.md file is still in the repository.
Use when alembic fails DuplicateObject enum on fresh DB.
Install
npx vskill@latest install lukemcqueen/hermes-cortex/alembic-enum-double-createSKILL.md
The same SKILL.md was published earlier as lukemcqueen/hermes-cortex/alembic-enum-double-create.
Alembic Enum Double-Create — Fresh DB Migration Crash
Symptom
alembic upgrade head fails on a fresh/empty database (e.g. after Docker volumes were deleted):
The api container crash-loops (health: starting forever), alembic_version is stuck at an older revision, and web never starts (depends_on: api service_healthy). The same failure replays on every restart because transactional DDL rolls the whole chain back.
Root cause
The migration does BOTH:
- Explicitly creates the enum:
sa.Enum(..., name="notification_type").create(op.get_bind()) - Declares table columns with
sa.Enum(..., name="notification_type", create_constraint=True)
create_constraint=True makes SQLAlchemy emit CREATE TYPE again during op.create_table (via Enum._on_table_create). Within one transaction the type gets created twice → DuplicateObject. This only shows on a fresh DB; an existing DB that already ran the migration never re-executes it, which is why the bug can sit unnoticed.
Fix
Remove the explicit .create() calls. The column definitions create each type exactly once during op.create_table:
Keep the downgrade dropping the types.
Verification
- Restart the api container (or rebuild +
docker compose up -d). docker logs api | grep -E "Running upgrade|✓|✗"→ all migrations run
through head, then ✓ Migrations up to date, uvicorn starts.
alembic currentreports the head revision.\dT+shows the enum types exist exactly once.
Pitfalls
- `docker cp` mode 600: copying a migration into a running container
lands with -rw------- owned by the host uid — the container user can't read it → PermissionError on next start. Fix: docker exec -u root api chmod 644 /app/alembic/versions/<file>.py.
- Baked `/app`: if the Dockerfile
COPYs the app (no volume mount for
code), docker cp is only a fast dev-loop test — rebuild the image so the fix survives docker compose up / ./run up.
- Stuck version is normal: after the failed run,
alembic_versionshows
the revision where the batch started (e.g. m10), not the failing one — the whole batch rolled back.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/software-development/alembic-enum-double-create/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/lukemcqueen/hermes-cortex/alembic-enum-double-create)