Files
shopdb-flask/migrations/MIGRATE_USB_DEVICES_FROM_EQUIPMENT.md
Cam Proudlock a9d0dfff4a Initial import: shopdb-flask multi-site asset platform
Flask + Vue rewrite of the classic-ASP shopdb, built as a plugin
framework so sister GE Aerospace sites can adopt it. Product version
0.7.0-pre-0.8.0, plugin contract 0.11.0, 966 backend tests.

Key entry points:
- docs/INSTALL-WINDOWS-IIS.md - tested Windows + IIS install runbook
  (own-site and subpath deployment methods)
- docs/PILOT-DEPLOY.md - production pilot: stand up + import + verify
- docs/IMPORT-API.md - schema-agnostic legacy data import contract
- scripts/site_imports/wjf/ - West Jefferson reference import loader
- docs/adr/ - twelve accepted architecture decision records
2026-07-14 07:58:51 -04:00

2.6 KiB

Migrate USB Devices from Equipment Table

Issue

6 USB devices were incorrectly stored in the equipment table instead of the proper usbdevices table.

Status

  • pin field added to usbdevices table for encrypted devices
  • pin field added to USBDevice model
  • USB Device equipment type deactivated (equipmenttypeid=44)
  • Migrate 6 USB devices to usbdevices table

Affected Records

Asset Number Name Serial Number
82841957-5891 Green Kingston 64GB 82841957
48854302-5892 Blue Kingston 64GB 48854302
75953637-5893 Blue Kingston 64GB USB 3.0 75953637
41299370-5904 Lenovo Portable DVD 41299370
15492331-5905 TEAC Portable Floppy Drive 15492331
25777358-5906 Netgear WiFi Adapter 25777358

Migration SQL

Step 1: Insert into usbdevices

INSERT INTO usbdevices (
    serialnumber,
    label,
    assetnumber,
    usbdevicetypeid,
    storagelocation,
    notes,
    createddate,
    modifieddate,
    isactive
)
SELECT
    a.serialnumber,
    a.name,
    a.assetnumber,
    NULL,  -- Assign proper type later
    NULL,  -- Storage location TBD
    a.notes,
    a.createddate,
    a.modifieddate,
    a.isactive
FROM assets a
JOIN equipment e ON e.assetid = a.assetid
WHERE e.equipmenttypeid = 44;  -- USB Device type

Step 2: Delete from equipment table

DELETE e FROM equipment e
JOIN assets a ON a.assetid = e.assetid
WHERE e.equipmenttypeid = 44;

Step 3: Delete from assets table

DELETE a FROM assets a
JOIN equipment e ON e.assetid = a.assetid
WHERE e.equipmenttypeid = 44;

-- Note: Run step 2 first since it references assets

Alternative: Manual Migration

Since there are only 6 devices, you may prefer to:

  1. Manually create them in the USB Devices section
  2. Delete the equipment/asset records

USB Device Types to Create

-- Check if types exist, create if needed
INSERT IGNORE INTO usbdevicetypes (typename, description, icon) VALUES
('Flash Drive', 'USB flash drive / thumb drive', 'usb'),
('External HDD', 'External hard disk drive', 'harddisk'),
('External SSD', 'External solid state drive', 'harddisk'),
('Card Reader', 'SD/CF card reader', 'sdcard'),
('Optical Drive', 'External CD/DVD/Blu-ray drive', 'disc'),
('WiFi Adapter', 'USB wireless network adapter', 'wifi'),
('Other', 'Other USB device', 'usb');

Notes

  • USB Device equipment type has been deactivated (isactive=0)
  • New USB devices should be created in the USB Devices section
  • USB devices do NOT need map positions (no mapleft/maptop)

Date Created

2026-01-27