diff --git a/migrations/versions/2026_08_13_1000-fe4970567bb3_tags.py b/migrations/versions/2026_08_13_1000-fe4970567bb3_tags.py index 7e6c732f..2c369be1 100644 --- a/migrations/versions/2026_08_13_1000-fe4970567bb3_tags.py +++ b/migrations/versions/2026_08_13_1000-fe4970567bb3_tags.py @@ -39,7 +39,6 @@ def upgrade() -> None: sa.Column("filament_id", sa.Integer(), nullable=True), sa.Column("target_value", sa.String(length=64), nullable=True), sa.Column("format", sa.String(length=32), nullable=True), - sa.Column("instance_uuid", sa.String(length=64), nullable=True), sa.Column("added", sa.DateTime(), nullable=False), sa.ForeignKeyConstraint( ["spool_id"], @@ -60,14 +59,10 @@ def upgrade() -> None: # The whole point of the table: one physical tag means exactly one thing, enforced by # the database rather than by whichever client happened to write last. op.create_index(op.f("ix_tag_uid"), "tag", ["uid"], unique=True) - # Not unique: see models.Tag. A payload copied onto a second sticker can carry one - # instance identity on two rows, both pointing at the same spool. - op.create_index(op.f("ix_tag_instance_uuid"), "tag", ["instance_uuid"], unique=False) def downgrade() -> None: """Perform the downgrade.""" - op.drop_index(op.f("ix_tag_instance_uuid"), table_name="tag") op.drop_index(op.f("ix_tag_uid"), table_name="tag") op.drop_index(op.f("ix_tag_filament_id"), table_name="tag") op.drop_index(op.f("ix_tag_spool_id"), table_name="tag") diff --git a/spoolman/database/models.py b/spoolman/database/models.py index 6f2930f6..0212f404 100644 --- a/spoolman/database/models.py +++ b/spoolman/database/models.py @@ -197,15 +197,4 @@ class Tag(Base): # Free-ish string (openprinttag, ntag, bambu, ...) rather than an enum: informational # in phase 1, and new tag types appear faster than migrations should. format: Mapped[str | None] = mapped_column(String(32)) - # Where phase 2 records a tag's decoded instance identity, so that rescanning a tag - # updates the spool it already created instead of making a second one. Nothing writes - # it yet -- it is here for the same reason the other unused columns are, that the - # table is the expensive half to change once it is populated on four databases, while - # the endpoint that fills it is additive and free. - # - # Indexed for that lookup and deliberately NOT unique. `uid` already enforces that one - # physical tag identifies one thing, and copying a tag's payload onto a second sticker - # (the case in the class docstring) can legitimately put one instance identity on two - # rows that point at the same spool -- which a unique constraint would reject. - instance_uuid: Mapped[str | None] = mapped_column(String(64), index=True) added: Mapped[datetime] = mapped_column()