Label switches from CODE128 to a QR encoding 'TAG|rev' (gage lab tag + latest print-file revision), so a physical part carries which revision it was printed from - short payload stays low-version + reliable at 0.5in (margin quiet zone, EC M, no logo). Item exposes latestrevision; kiosk strips the |rev to resolve and records the scanned revision on the take (migration 0004 adds printeditemtransactions.revision) for traceability of which rev was consumed. Manual entry records a null revision.
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
"""printedparts: printeditemtransactions.revision (traceability)
|
|
|
|
Records which print-file revision the physical part carried when it was taken,
|
|
captured from the label QR (gage tag + revision). Nullable - manual entry and
|
|
pre-QR labels have no revision. Idempotent guard.
|
|
|
|
Revision ID: printedparts0004txnrev
|
|
Revises: printedparts0003gagetag
|
|
Create Date: 2026-07-21
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision = 'printedparts0004txnrev'
|
|
down_revision = 'printedparts0003gagetag'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def _has_col(insp):
|
|
return any(c['name'] == 'revision'
|
|
for c in insp.get_columns('printeditemtransactions'))
|
|
|
|
|
|
def upgrade():
|
|
bind = op.get_bind()
|
|
insp = sa.inspect(bind)
|
|
if 'printeditemtransactions' not in insp.get_table_names():
|
|
return
|
|
if not _has_col(insp):
|
|
op.add_column('printeditemtransactions',
|
|
sa.Column('revision', sa.Integer(), nullable=True))
|
|
|
|
|
|
def downgrade():
|
|
bind = op.get_bind()
|
|
insp = sa.inspect(bind)
|
|
if 'printeditemtransactions' not in insp.get_table_names():
|
|
return
|
|
if _has_col(insp):
|
|
op.drop_column('printeditemtransactions', 'revision')
|