printedparts: QR label tag+rev, record taken revision

This commit is contained in:
2026-07-22 07:52:17 -04:00
parent 6a8a056b9b
commit d49f0cbb09
6 changed files with 151 additions and 34 deletions

View File

@@ -0,0 +1,43 @@
"""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')