feat(UI-Overhaul-Phase6): Tags Umstrukturierung
Check Cross-Plugin Imports / check (push) Has been cancelled
Check Cross-Plugin Imports / check (push) Has been cancelled
Migration 0138: Add parent_id, applicable_to, icon columns to tags table Backend: - Tag model: add parent_id (self-FK), applicable_to (JSONB), icon (VARCHAR) - TagCreate/TagUpdate/TagResponse schemas: add new fields - Tags routes: create_tag, update_tag, list_tags return new fields Frontend: - api/tags.ts: Tag interface, CreateTagPayload, UpdateTagPayload updated with new fields - Tags route moved from /tags to /settings/tags (under Settings) - Tags.tsx: TagFormModal updated with parent tag selector, icon picker, applicable_to multi-select - TagsPage passes tags list to TagFormModal for parent selection tsc clean, backend import OK
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""Tags: parent_id, applicable_to, icon columns
|
||||
|
||||
Revision ID: 0138
|
||||
Revises: 0137
|
||||
Create Date: 2026-08-21
|
||||
|
||||
Adds parent_id for tree structure, applicable_to for entity-type filtering,
|
||||
and icon for per-tag icon selection.
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects.postgresql import UUID as PGUUID, JSONB
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "0138"
|
||||
down_revision = "0137"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# parent_id for tree structure (self-referencing FK)
|
||||
op.add_column("tags", sa.Column("parent_id", PGUUID(as_uuid=True), nullable=True))
|
||||
op.create_foreign_key(
|
||||
"fk_tags_parent_id", "tags", "tags", ["parent_id"], ["id"], ondelete="SET NULL"
|
||||
)
|
||||
op.create_index("ix_tags_parent", "tags", ["parent_id"])
|
||||
|
||||
# applicable_to: list of entity types where this tag can be applied
|
||||
op.add_column("tags", sa.Column("applicable_to", JSONB, nullable=True))
|
||||
|
||||
# icon: icon name for frontend display
|
||||
op.add_column("tags", sa.Column("icon", sa.String(50), nullable=True))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("tags", "icon")
|
||||
op.drop_column("tags", "applicable_to")
|
||||
op.drop_index("ix_tags_parent", table_name="tags")
|
||||
op.drop_constraint("fk_tags_parent_id", "tags", type_="foreignkey")
|
||||
op.drop_column("tags", "parent_id")
|
||||
Reference in New Issue
Block a user