Skip to content

Fix migration 0004 aborting when ix_tags_tag_type is missing - #15252

Open
Constantine1916 wants to merge 1 commit into
Comfy-Org:masterfrom
Constantine1916:fix/migration-drop-missing-index
Open

Fix migration 0004 aborting when ix_tags_tag_type is missing#15252
Constantine1916 wants to merge 1 commit into
Comfy-Org:masterfrom
Constantine1916:fix/migration-drop-missing-index

Conversation

@Constantine1916

Copy link
Copy Markdown

Fixes #15022

Summary

  • Migration 0004_drop_tag_type unconditionally calls drop_index("ix_tags_tag_type"). Databases in the wild can be at revision 0003 without that index (tables created by older builds), so the whole upgrade aborts with ValueError: No such index: 'ix_tags_tag_type' and ComfyUI fails to start.
  • Inspect the existing indexes on tags and only drop the index when it is present. The tag_type column is still dropped either way, so the resulting schema is identical in both cases.

Testing

  • New regression test: upgrade to 0003, drop the index to simulate the wild state, upgrade to head — previously raised ValueError, now succeeds and tag_type is gone.
  • .venv/bin/python -m pytest tests-unit/app_test/test_migrations.py -q (5 passed)
  • .venv/bin/python -m ruff check .

Databases created by older builds can be at revision 0003 without
ix_tags_tag_type on the tags table. The unconditional drop_index in
0004_drop_tag_type then aborts the whole upgrade with
"ValueError: No such index" and ComfyUI fails to start.

Inspect the existing indexes and only drop the index when present;
the tag_type column is still dropped either way.
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9495854b-0fa2-4b89-bb2b-4fceb7bbaebc

📥 Commits

Reviewing files that changed from the base of the PR and between 14b0522 and 096bbcd.

📒 Files selected for processing (2)
  • alembic_db/versions/0004_drop_tag_type.py
  • tests-unit/app_test/test_migrations.py
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (4)
**/*

📄 CodeRabbit inference engine (AGENTS.md)

**/*: Keep changes and file scope as small and direct as possible; prefer practical fixes, minimal dependencies, existing patterns, and removal of obsolete code.
Preserve existing APIs, node names, model-loading behavior, file layout, and workflow compatibility unless replacement is intentional.
Do not add core ComfyUI code that makes outbound internet requests, including telemetry, analytics, tracking, reporting, update checks, remote configuration, licensing checks, or background network activity. User-authorized model downloads are permitted only for the requested artifact and without telemetry.
Keep state and capability flags on the object that owns the behavior; prefer explicit parent-owned attributes over probing child objects with getattr for parent control flow.
Preserve shared method signatures, argument conventions, return types, side effects, and error behavior unless the shared contract and all affected callers are intentionally updated.

Files:

  • alembic_db/versions/0004_drop_tag_type.py
  • tests-unit/app_test/test_migrations.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Do not add torch.no_grad, torch.inference_mode, inference-mode wrappers, or explicit model freeze/trainability toggles; only disable globally enabled inference mode when a training path needs gradients.
Remove inference-only training behavior such as dropout while preserving checkpoint and state-dict compatibility; use nn.Identity when removing a module would alter keys or ordering.
Keep imports at module scope except for established optional-backend probes or import-cycle avoidance; avoid unnecessary exception handling and use specific exception types with useful fallbacks.
Do not add code for unsupported pinned library versions or obsolete PyTorch workarounds; unsupported formats, invalid quantization metadata, and bad states should fail clearly rather than silently degrading output.
Match local Python style, keep comments sparse and useful, and remove comments that merely restate obvious code.
Treat dtype, device placement, VRAM usage, and offloading as correctness concerns; use existing ComfyUI cast, offload, cleanup, quantization, and memory helpers.
Model implementations must use an existing optimized Comfy Kitchen, ComfyUI, quantization, or backend operation when it supports the required math, layout, dtype, device, memory, and interface contracts; inspect available operations before writing local kernels.
Retain local or differentiable fallbacks only when no optimized operation satisfies the required math or patch/autograd contract; adapt inputs to shared operation layouts while preserving exact model behavior.
Treat optimized attention and similar backend-selected callables as opaque; callers must rely on documented interfaces and result contracts rather than function identity, names, modules, or implementation details.
Do not duplicate existing inference operations with custom float32-upcasting implementations, such as custom RMSNorm variants; use generic ComfyUI or native torch operations.
If a model constructor has an operations parame...

Files:

  • alembic_db/versions/0004_drop_tag_type.py
  • tests-unit/app_test/test_migrations.py
**

⚙️ CodeRabbit configuration file

**: IMPORTANT: Only comment on issues directly introduced by this PR's code changes.
Treat AGENTS.md as mandatory repository policy, not optional style guidance.
Flag PR changes that violate AGENTS.md even when the code is otherwise functional.
In particular, enforce architecture boundaries, dtype/device/memory rules,
interface contracts, import style, no unnecessary try/except blocks, no inline
imports, no outbound internet paths in core ComfyUI, and narrow scoped fixes.
Prefer direct findings over suggestions when a rule is violated. Only ignore
AGENTS.md when it clearly conflicts with a newer explicit maintainer instruction
in the PR.
Do NOT flag pre-existing issues in code that was merely moved, re-indented,
de-indented, or reformatted without logic changes. If code appears in the diff
only due to whitespace or structural reformatting (e.g., removing a with: block),
treat it as unchanged. Contributors should not feel obligated to address
pre-existing issues outside the scope of their contribution.

Files:

  • alembic_db/versions/0004_drop_tag_type.py
  • tests-unit/app_test/test_migrations.py
alembic_db/**

⚙️ CodeRabbit configuration file

alembic_db/**: Database migrations. Focus on:

  • Migration safety and rollback support
  • Data preservation during schema changes

Files:

  • alembic_db/versions/0004_drop_tag_type.py
🧠 Learnings (1)
📚 Learning: 2026-02-21T14:01:41.482Z
Learnt from: pythongosssss
Repo: Comfy-Org/ComfyUI PR: 12555
File: comfy_extras/nodes_glsl.py:719-724
Timestamp: 2026-02-21T14:01:41.482Z
Learning: In PyOpenGL, bare Python scalars can be accepted for 1-element array parameters by NumberHandler. This means you can pass an int/float directly to OpenGL texture deletion (e.g., glDeleteTextures(tex)) without wrapping in a list. Verify function-specific expectations and ensure types match what the OpenGL call expects; use explicit lists only when the API requires an array.

Applied to files:

  • alembic_db/versions/0004_drop_tag_type.py
  • tests-unit/app_test/test_migrations.py
🔇 Additional comments (2)
alembic_db/versions/0004_drop_tag_type.py (1)

24-32: LGTM!

tests-unit/app_test/test_migrations.py (1)

54-70: LGTM!


📝 Walkthrough

Walkthrough

The revision 0004 migration now checks whether ix_tags_tag_type exists before dropping it. The migration still removes the tag_type column. A regression test covers a SQLite database at revision 0003 with the index removed before upgrading to head.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the migration failure and the missing index condition.
Description check ✅ Passed The description explains the migration failure, the fix, and the regression test related to the changeset.
Linked Issues check ✅ Passed The migration conditionally drops the missing index and always removes tag_type, satisfying issue #15022.
Out of Scope Changes check ✅ Passed The changes are limited to the migration fix and its regression test for issue #15022.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ValueError: No such index: 'ix_tags_tag_type'

1 participant