character-fandom tag association system

Link character tags to fandom tags via fandom_id FK with auto-apply
behavior. Adding character:Saber (Fate) auto-creates fandom:Fate and
applies it to the image. Renaming a fandom cascades to all linked
characters. Includes set-fandom endpoint for retroactive association
and fandom selector dropdown in the tag editor UI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-11 19:53:02 -05:00
parent 3a30b876a2
commit bf20eeab5c
6 changed files with 362 additions and 18 deletions
@@ -0,0 +1,30 @@
"""Add fandom_id to tag for character-fandom association
Revision ID: f26021101
Revises: e26012202
Create Date: 2026-02-11
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'f26021101'
down_revision = 'e26012202'
branch_labels = None
depends_on = None
def upgrade():
op.add_column('tag', sa.Column('fandom_id', sa.Integer(), nullable=True))
op.create_foreign_key(
'fk_tag_fandom_id', 'tag', 'tag',
['fandom_id'], ['id'],
ondelete='SET NULL'
)
def downgrade():
op.drop_constraint('fk_tag_fandom_id', 'tag', type_='foreignkey')
op.drop_column('tag', 'fandom_id')