Files
shopdb/sql/migration_phase4/VERIFY_PHASE4_MIGRATION.sql
cproudlock 65b622c361 Add USB checkout system and SSO profile page
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>
2025-12-07 11:16:14 -05:00

128 lines
4.1 KiB
SQL

-- =====================================================
-- VERIFY PHASE 4 MIGRATION: Application Versions
-- =====================================================
-- Date: 2025-11-25
-- Purpose: Verify all Phase 4 schema changes are in place
-- Run this after all migration scripts complete
-- =====================================================
USE shopdb;
SELECT '=================================================' AS '';
SELECT 'PHASE 4 MIGRATION VERIFICATION' AS '';
SELECT '=================================================' AS '';
-- =====================================================
-- CHECK 1: appversions table exists
-- =====================================================
SELECT '--- CHECK 1: appversions table ---' AS '';
SELECT
CASE WHEN COUNT(*) > 0 THEN '✓ PASS' ELSE '✗ FAIL' END AS appversions_table_exists
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'shopdb' AND TABLE_NAME = 'appversions';
SELECT
COLUMN_NAME,
DATA_TYPE,
IS_NULLABLE,
COLUMN_KEY
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'shopdb' AND TABLE_NAME = 'appversions'
ORDER BY ORDINAL_POSITION;
-- =====================================================
-- CHECK 2: installedapps.appversionid column exists
-- =====================================================
SELECT '--- CHECK 2: installedapps.appversionid column ---' AS '';
SELECT
CASE WHEN COUNT(*) > 0 THEN '✓ PASS' ELSE '✗ FAIL' END AS appversionid_column_exists
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'shopdb'
AND TABLE_NAME = 'installedapps'
AND COLUMN_NAME = 'appversionid';
-- Check FK
SELECT
CASE WHEN COUNT(*) > 0 THEN '✓ PASS' ELSE '✗ FAIL' END AS installedapps_fk_exists
FROM information_schema.TABLE_CONSTRAINTS
WHERE TABLE_SCHEMA = 'shopdb'
AND TABLE_NAME = 'installedapps'
AND CONSTRAINT_NAME = 'fk_installedapps_appversionid';
-- =====================================================
-- CHECK 3: notifications.appid column exists
-- =====================================================
SELECT '--- CHECK 3: notifications.appid column ---' AS '';
SELECT
CASE WHEN COUNT(*) > 0 THEN '✓ PASS' ELSE '✗ FAIL' END AS notifications_appid_column_exists
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'shopdb'
AND TABLE_NAME = 'notifications'
AND COLUMN_NAME = 'appid';
-- Check FK
SELECT
CASE WHEN COUNT(*) > 0 THEN '✓ PASS' ELSE '✗ FAIL' END AS notifications_appid_fk_exists
FROM information_schema.TABLE_CONSTRAINTS
WHERE TABLE_SCHEMA = 'shopdb'
AND TABLE_NAME = 'notifications'
AND CONSTRAINT_NAME = 'fk_notifications_appid';
-- =====================================================
-- CHECK 4: Foreign key relationships
-- =====================================================
SELECT '--- CHECK 4: Foreign key relationships ---' AS '';
SELECT
CONSTRAINT_NAME,
TABLE_NAME,
REFERENCED_TABLE_NAME
FROM information_schema.REFERENTIAL_CONSTRAINTS
WHERE CONSTRAINT_SCHEMA = 'shopdb'
AND (
CONSTRAINT_NAME LIKE '%appversion%'
OR (TABLE_NAME = 'notifications' AND CONSTRAINT_NAME LIKE '%appid%')
);
-- =====================================================
-- SUMMARY: Current record counts
-- =====================================================
SELECT '--- SUMMARY: Record counts ---' AS '';
SELECT
'applications' AS table_name,
COUNT(*) AS record_count
FROM applications
UNION ALL
SELECT
'appversions' AS table_name,
COUNT(*) AS record_count
FROM appversions
UNION ALL
SELECT
'installedapps' AS table_name,
COUNT(*) AS record_count
FROM installedapps
UNION ALL
SELECT
'installedapps (with version)' AS table_name,
COUNT(*) AS record_count
FROM installedapps WHERE appversionid IS NOT NULL
UNION ALL
SELECT
'notifications' AS table_name,
COUNT(*) AS record_count
FROM notifications
UNION ALL
SELECT
'notifications (app-linked)' AS table_name,
COUNT(*) AS record_count
FROM notifications WHERE appid IS NOT NULL;
SELECT '=================================================' AS '';
SELECT 'PHASE 4 VERIFICATION COMPLETE' AS '';
SELECT '=================================================' AS '';