USB external import, and filter chips on health-dot cards
This commit is contained in:
49
plugins/usb/migrations/versions/0003_checkout_scan_fields.py
Normal file
49
plugins/usb/migrations/versions/0003_checkout_scan_fields.py
Normal file
@@ -0,0 +1,49 @@
|
||||
"""Record whether a returned drive was virus-scanned.
|
||||
|
||||
The external cmmc_usb checkinoutlog carries scanned_viruses and sanitized on
|
||||
every row. The self-hosted usbcheckouts table already has waswiped, which is
|
||||
the same fact as sanitized under a different name, but nothing corresponds to
|
||||
scanned_viruses. That gap was harmless while the two backends were
|
||||
alternatives, and becomes data loss the moment a site imports its history and
|
||||
cuts over: whether a returned drive was scanned is precisely what a
|
||||
removable-media audit asks.
|
||||
|
||||
Nullable on purpose, and NOT defaulted to false. A checkout recorded before
|
||||
this column existed is not a checkout where the drive went unscanned; it is one
|
||||
where nobody wrote it down. False would assert something the data does not say.
|
||||
|
||||
Idempotent, so a re-run on an already-migrated database is a no-op.
|
||||
|
||||
Revision ID: usb0003scanfields
|
||||
Revises: usb0002dropmachineid
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = 'usb0003scanfields'
|
||||
down_revision = 'usb0002dropmachineid'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
bind = op.get_bind()
|
||||
insp = sa.inspect(bind)
|
||||
if 'usbcheckouts' not in insp.get_table_names():
|
||||
return
|
||||
cols = {c['name'] for c in insp.get_columns('usbcheckouts')}
|
||||
if 'scannedviruses' not in cols:
|
||||
op.add_column('usbcheckouts',
|
||||
sa.Column('scannedviruses', sa.Boolean(), nullable=True))
|
||||
|
||||
|
||||
|
||||
def downgrade():
|
||||
bind = op.get_bind()
|
||||
insp = sa.inspect(bind)
|
||||
if 'usbcheckouts' not in insp.get_table_names():
|
||||
return
|
||||
cols = {c['name'] for c in insp.get_columns('usbcheckouts')}
|
||||
if 'scannedviruses' in cols:
|
||||
op.drop_column('usbcheckouts', 'scannedviruses')
|
||||
Reference in New Issue
Block a user