feat(maintenance): backfill fandom tags onto legacy character attachments
New Celery task sync_character_fandoms_to_images on the maintenance queue. For every character tag with a non-null fandom_id, runs the same INSERT ... SELECT ... ON CONFLICT DO NOTHING that set_tag_fandom already runs inline, attaching the fandom tag to every image that has the character attached. Why this exists: migration j26042101 extracted the '(Fandom)' suffix from pre-refactor character names into tag.fandom_id, but it did NOT walk image_tags to attach the fandom rows to every image that had the character. Post-refactor auto-apply (in add_tag / accept_image_suggestion / set_tag_fandom) only fires on NEW add/accept events — pre-existing character attachments from before the migration still show the character pill in the modal but no fandom pill, because the fandom row was never added to image_tags. Surfaced by Settings → Maintenance → 'Sync fandoms to images'. Safe, additive, idempotent. Run once after the migration to close the gap; subsequent set-fandom operations continue to maintain the invariant inline. Verified locally: seeded a character+fandom pair with only the character attached to image 1; task added the fandom to image_tags; final state has both rows. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -456,6 +456,18 @@
|
||||
<button type="submit" class="btn secondary-btn">Recompute all centroids</button>
|
||||
</form>
|
||||
|
||||
<p class="settings-hint mt-paragraph">
|
||||
For every character tag with a fandom assigned, attach the fandom
|
||||
tag to every image already tagged with that character. Additive
|
||||
only — never removes fandom attachments. Safe to re-run. Backfills
|
||||
data migrated from pre-refactor tag names that embedded the
|
||||
"(Fandom)" suffix, since the migration set tag.fandom_id but did
|
||||
not retroactively attach the fandom row to image_tags.
|
||||
</p>
|
||||
<form action="{{ url_for('main.trigger_sync_character_fandoms_to_images') }}" method="post" onsubmit="return confirm('Attach each character\\'s fandom tag to every image with that character?');">
|
||||
<button type="submit" class="btn secondary-btn">Sync fandoms to images</button>
|
||||
</form>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="settings-section">
|
||||
|
||||
Reference in New Issue
Block a user