New Features: - USB Device checkout/check-in system with barcode scanning - displayusb.asp: List all USB devices with status - addusb.asp: Add new USB devices via barcode scan - checkout_usb.asp/savecheckout_usb.asp: Check out USB to SSO - checkin_usb.asp/savecheckin_usb.asp: Check in with wipe confirmation - usb_history.asp: Full checkout history with filters - api_usb.asp: JSON API for AJAX lookups - displayprofile.asp: SSO profile page showing user info and USB history - Date/time format changed to 12-hour (MM/DD/YYYY h:mm AM/PM) - SSO links in USB history now link to profile page via search Database: - New machinetypeid 44 for USB devices - New usb_checkouts table for tracking checkouts Cleanup: - Removed v2 folder (duplicate/old files) - Removed old debug/test files - Removed completed migration documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Phase 4 Migration: Application Versions
Date: 2025-11-25 Status: Ready for deployment
Overview
This migration adds application version tracking to ShopDB:
appversionstable - Stores version strings for each applicationinstalledapps.appversionid- Links installed apps to specific versionsnotifications.appid- Optional link from notifications to applications
Schema Changes
New Table: appversions
CREATE TABLE appversions (
appversionid INT PRIMARY KEY AUTO_INCREMENT,
appid TINYINT(4) NOT NULL, -- FK to applications
version VARCHAR(50) NOT NULL, -- Version string (e.g., "2.1.0.45")
releasedate DATE NULL, -- Optional release date
notes VARCHAR(255) NULL, -- Optional notes
isactive BIT(1) DEFAULT 1,
dateadded DATETIME DEFAULT NOW(),
UNIQUE KEY (appid, version) -- One entry per app+version combo
);
Modified Table: installedapps
-- Added column:
appversionid INT NULL -- FK to appversions (NULL for legacy records)
Modified Table: notifications
-- Added column:
appid TINYINT(4) NULL -- FK to applications (optional app association)
Files
| File | Purpose |
|---|---|
01_create_appversions_table.sql |
Creates the appversions table |
02_add_appversionid_to_installedapps.sql |
Adds version FK to installedapps |
03_add_appid_to_notifications.sql |
Adds app FK to notifications |
VERIFY_PHASE4_MIGRATION.sql |
Verifies all changes |
RUN_ALL_PHASE4_SCRIPTS.sql |
Runs all scripts in order |
ROLLBACK_01_appversions_table.sql |
Drops appversions table |
ROLLBACK_02_installedapps_appversionid.sql |
Removes installedapps column |
ROLLBACK_03_notifications_appid.sql |
Removes notifications column |
Deployment Instructions
Prerequisites
-
Create database backup:
mysqldump -u root -p shopdb > shopdb_backup_$(date +%Y%m%d_%H%M%S).sql -
Verify current schema:
mysql -u root -p shopdb -e "DESCRIBE installedapps; DESCRIBE notifications;"
Run Migration
Option A: Run all scripts at once
cd /path/to/sql/migration_phase4
mysql -u root -p shopdb < RUN_ALL_PHASE4_SCRIPTS.sql
Option B: Run scripts individually
mysql -u root -p shopdb < 01_create_appversions_table.sql
mysql -u root -p shopdb < 02_add_appversionid_to_installedapps.sql
mysql -u root -p shopdb < 03_add_appid_to_notifications.sql
mysql -u root -p shopdb < VERIFY_PHASE4_MIGRATION.sql
Verify Success
mysql -u root -p shopdb < VERIFY_PHASE4_MIGRATION.sql
All checks should show ✓ PASS.
Rollback Instructions
If you need to rollback, run scripts in reverse order:
mysql -u root -p shopdb < ROLLBACK_03_notifications_appid.sql
mysql -u root -p shopdb < ROLLBACK_02_installedapps_appversionid.sql
mysql -u root -p shopdb < ROLLBACK_01_appversions_table.sql
Warning: Rolling back ROLLBACK_01 will delete all version data.
Post-Migration: Code Changes Required
1. api.asp - Update GetOrCreateApplication()
The function needs to:
- Look up or create the application in
applications - Look up or create the version in
appversions - Return
appversionidto store ininstalledapps
2. api.asp - Update UpdateInstalledApps()
Change INSERT to include appversionid:
INSERT INTO installedapps (machineid, appid, appversionid, isactive)
VALUES (?, ?, ?, ?)
3. Notification forms (addnotification.asp, editnotification.asp)
Add optional application dropdown to link notifications to apps.
4. Display pages
displayinstalledapps.asp- Show version columndisplaynotifications.asp- Show linked app name
Example Queries
Get installed apps with versions
SELECT
m.hostname,
a.appname,
av.version,
ia.isactive
FROM installedapps ia
JOIN machines m ON ia.machineid = m.machineid
JOIN applications a ON ia.appid = a.appid
LEFT JOIN appversions av ON ia.appversionid = av.appversionid
WHERE m.pctypeid IS NOT NULL
ORDER BY m.hostname, a.appname;
Get notifications with linked apps
SELECT
n.notification,
n.starttime,
n.endtime,
a.appname AS related_app
FROM notifications n
LEFT JOIN applications a ON n.appid = a.appid
WHERE n.isactive = 1
ORDER BY n.starttime DESC;
Find all versions of a specific app
SELECT
a.appname,
av.version,
av.releasedate,
COUNT(ia.machineid) AS install_count
FROM applications a
JOIN appversions av ON a.appid = av.appid
LEFT JOIN installedapps ia ON av.appversionid = ia.appversionid
WHERE a.appname LIKE '%PC-DMIS%'
GROUP BY a.appid, av.appversionid
ORDER BY av.version DESC;