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>
This commit is contained in:
@@ -1,214 +1,166 @@
|
||||
# Database Migration - Current Status Summary
|
||||
# Database Migration - Status Summary
|
||||
|
||||
**Date:** 2025-11-06
|
||||
**Session End:** Ready to create Phase 1 SQL scripts
|
||||
**Status:** Design 100% Complete ✅
|
||||
**Last Updated:** 2025-11-25
|
||||
**Current Phase:** Phase 2 COMPLETE, Phase 3 PLANNED
|
||||
|
||||
---
|
||||
|
||||
## Design Complete ✅
|
||||
## Migration Status
|
||||
|
||||
All design decisions finalized and documented:
|
||||
|
||||
1. ✅ Communications infrastructure (generic `address` field)
|
||||
2. ✅ Compliance tracking (from inventory.xlsx)
|
||||
3. ✅ Warranty management (simplified)
|
||||
4. ✅ Machine relationships (dualpath, controller associations)
|
||||
5. ✅ Controller fields (controllertypeid, controllerosid)
|
||||
6. ✅ 100% inventory.xlsx column coverage (35/35 columns)
|
||||
| Phase | Status | Description | Completed |
|
||||
|-------|--------|-------------|-----------|
|
||||
| **Phase 1** | COMPLETE | Schema changes (tables, columns, indexes) | Nov 6, 2025 |
|
||||
| **Phase 2** | COMPLETE | PC migration to machines table | Nov 10, 2025 |
|
||||
| **Phase 3** | COMPLETE | Network devices - legacy tables dropped | Nov 25, 2025 |
|
||||
|
||||
---
|
||||
|
||||
## Final Table Counts
|
||||
## Phase 1: Schema Changes (COMPLETE)
|
||||
|
||||
**New Tables:** 7
|
||||
1. comstypes (8 columns)
|
||||
2. communications (9 columns)
|
||||
3. compliance (15 columns) - includes MFT
|
||||
4. compliancescans (5 columns)
|
||||
5. warranties (5 columns)
|
||||
6. relationshiptypes (5 columns)
|
||||
7. machinerelationships (6 columns)
|
||||
**Completed:** November 6, 2025
|
||||
|
||||
**Modified Tables:** 2
|
||||
1. machines (+11 columns) - now 21 total
|
||||
2. businessunits (+2 columns) - now 6 total
|
||||
### New Tables Created (7)
|
||||
1. `comstypes` - Communication types (IP, Serial, etc.)
|
||||
2. `communications` - Unified network interfaces
|
||||
3. `warranties` - Warranty tracking
|
||||
4. `compliance` - Compliance tracking
|
||||
5. `compliancescans` - Scan history
|
||||
6. `relationshiptypes` - Relationship type definitions
|
||||
7. `machinerelationships` - Machine-to-machine relationships
|
||||
|
||||
**Renamed:** pcstatus → machinestatus
|
||||
### Tables Modified (2)
|
||||
1. `machines` - Added 11 columns (hostname, serialnumber, osid, pctypeid, etc.)
|
||||
2. `businessunits` - Added liaison fields
|
||||
|
||||
**Deprecated:** pc, pc_comm_config, pc_network_interfaces, pctype
|
||||
|
||||
**Total New Columns:** 61
|
||||
### Tables Renamed
|
||||
- `pcstatus` → `machinestatus`
|
||||
|
||||
---
|
||||
|
||||
## Final machines Table (21 columns)
|
||||
## Phase 2: PC Migration (COMPLETE)
|
||||
|
||||
1. machineid (PK)
|
||||
2. machinetypeid (FK) - includes PC types
|
||||
3. machinenumber
|
||||
4. alias
|
||||
5. hostname (NEW - for PCs)
|
||||
6. serialnumber (NEW)
|
||||
7. loggedinuser (NEW - for PCs)
|
||||
8. modelnumberid (FK)
|
||||
9. **controllertypeid (NEW - for CNCs)**
|
||||
10. **controllerosid (NEW - controller OS)**
|
||||
11. **osid (NEW - for PCs)**
|
||||
12. machinestatusid (NEW)
|
||||
13. businessunitid (FK)
|
||||
14. printerid (FK)
|
||||
15. mapleft
|
||||
16. maptop
|
||||
17. isactive
|
||||
18. islocationonly
|
||||
19. machinenotes
|
||||
20. lastupdated (NEW)
|
||||
21. dateadded (NEW)
|
||||
**Completed:** November 10, 2025
|
||||
|
||||
**Key:** Both PC OS and Controller OS use the same `operatingsystems` table!
|
||||
### Data Migrated
|
||||
- **277 PCs** migrated from `pc` table → `machines` table
|
||||
- **705+ network interfaces** → `communications` table
|
||||
- **Dualpath relationships** → `machinerelationships` table
|
||||
- **PC→Equipment relationships** → `machinerelationships` table
|
||||
|
||||
### Schema Changes
|
||||
- PCs identified by `pctypeid IS NOT NULL` in machines table
|
||||
- Network interfaces use `communications.address` field
|
||||
- Relationships use `machinerelationships` table
|
||||
|
||||
### Pages Updated
|
||||
- displaypcs.asp, displaypc.asp, editpc.asp
|
||||
- displaymachines.asp, displaymachine.asp
|
||||
- network_map.asp, network_devices.asp
|
||||
- All save/update device pages
|
||||
|
||||
### API Fixes
|
||||
- Fixed 36+ IIf() bugs in api.asp
|
||||
- Fixed PC→Machine relationship creation
|
||||
- PowerShell data collection fully working
|
||||
|
||||
---
|
||||
|
||||
## Inventory.xlsx Coverage: 100% (35/35)
|
||||
## Phase 3: Network Devices (COMPLETE)
|
||||
|
||||
All columns mapped to database:
|
||||
- ✅ VLAN → communications.settings JSON
|
||||
- ✅ MFT → compliance.mft
|
||||
- ✅ OT Asset Fields → machinerelationships table
|
||||
**Completed:** November 25, 2025
|
||||
|
||||
See: `INVENTORY_COLUMN_MAPPING.md` for complete mapping
|
||||
### What Happened
|
||||
- Legacy tables were essentially empty (only 3 servers had data)
|
||||
- Network devices were already being added directly to `machines` table
|
||||
- Dropped all legacy network device tables
|
||||
|
||||
### Tables Dropped
|
||||
- `servers` (3 records - not migrated, stale data)
|
||||
- `switches` (empty)
|
||||
- `cameras` (empty)
|
||||
- `accesspoints` (empty)
|
||||
- `idfs` (empty)
|
||||
|
||||
### Current Network Device Types in machines Table
|
||||
| machinetypeid | Type |
|
||||
|---------------|------|
|
||||
| 16 | Access Point |
|
||||
| 17 | IDF |
|
||||
| 18 | Camera |
|
||||
| 19 | Switch |
|
||||
| 20 | Server |
|
||||
|
||||
### Printers
|
||||
- Stay in separate `printers` table (by design - unique fields, workflows)
|
||||
|
||||
---
|
||||
|
||||
## Documentation Files
|
||||
## Current Architecture
|
||||
|
||||
1. **DATABASE_MIGRATION_FINAL_DESIGN.md** (23KB)
|
||||
- Complete specification
|
||||
- All table structures
|
||||
- Migration strategy
|
||||
- Risk mitigation
|
||||
```
|
||||
machines table (unified)
|
||||
├── Equipment (machinetypeid 1-24, pctypeid IS NULL)
|
||||
├── PCs (machinetypeid 25-29, pctypeid IS NOT NULL)
|
||||
└── [Future] Network Devices (machinetypeid 30-36)
|
||||
|
||||
2. **MIGRATION_QUICK_REFERENCE.md** (4.6KB)
|
||||
- Quick lookup
|
||||
- Table summaries
|
||||
- Key decisions
|
||||
printers table (separate)
|
||||
|
||||
3. **MACHINE_RELATIONSHIPS_EXAMPLES.md** (9.4KB)
|
||||
- Real-world examples
|
||||
- Query patterns
|
||||
- ASP code samples
|
||||
communications table (all network interfaces)
|
||||
|
||||
4. **INVENTORY_COLUMN_MAPPING.md** (NEW - 8KB)
|
||||
- 100% column coverage
|
||||
- Export query
|
||||
- Mapping notes
|
||||
machinerelationships table (all relationships)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Next Steps (When Ready)
|
||||
## Key Queries
|
||||
|
||||
### Phase 1: Create SQL Scripts (8 scripts)
|
||||
```sql
|
||||
-- All PCs
|
||||
SELECT * FROM machines WHERE pctypeid IS NOT NULL;
|
||||
|
||||
1. **Script 01:** Create communications infrastructure
|
||||
- comstypes table
|
||||
- communications table
|
||||
-- All Equipment (non-PC)
|
||||
SELECT * FROM machines WHERE pctypeid IS NULL;
|
||||
|
||||
2. **Script 02:** Extend machines table
|
||||
- Add 11 new columns
|
||||
- Add indexes and FKs
|
||||
-- PCs with network info
|
||||
SELECT m.hostname, m.serialnumber, c.address
|
||||
FROM machines m
|
||||
LEFT JOIN communications c ON m.machineid = c.machineid
|
||||
WHERE m.pctypeid IS NOT NULL;
|
||||
|
||||
3. **Script 03:** Create PC machine types
|
||||
- Insert into machinetypes table
|
||||
|
||||
4. **Script 04:** Create warranty infrastructure
|
||||
- warranties table
|
||||
|
||||
5. **Script 05:** Create compliance infrastructure
|
||||
- compliance table (15 columns - includes MFT)
|
||||
- compliancescans table
|
||||
|
||||
6. **Script 06:** Extend businessunits table
|
||||
- Add liaisonname, liaisonsso
|
||||
|
||||
7. **Script 07:** Rename pcstatus to machinestatus
|
||||
- RENAME TABLE
|
||||
- Rename columns
|
||||
|
||||
8. **Script 08:** Create machine relationships infrastructure
|
||||
- relationshiptypes table
|
||||
- machinerelationships table
|
||||
|
||||
**Plus:** 8 corresponding rollback scripts
|
||||
|
||||
**Estimated Time:** 25 minutes
|
||||
**Reversibility:** Full (rollback scripts provided)
|
||||
-- PC → Equipment relationships
|
||||
SELECT
|
||||
pc.hostname AS pc_name,
|
||||
eq.machinenumber AS equipment_name
|
||||
FROM machinerelationships mr
|
||||
JOIN machines pc ON mr.machineid = pc.machineid
|
||||
JOIN machines eq ON mr.related_machineid = eq.machineid
|
||||
JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid
|
||||
WHERE rt.relationshiptype = 'Controls';
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Key Design Decisions
|
||||
## Deprecated Tables (Phase 2)
|
||||
|
||||
### ✅ Generic `address` Field
|
||||
One field for IP, COM1, USB, etc. Type determined by `comstypeid`.
|
||||
These tables are deprecated but kept for rollback safety:
|
||||
|
||||
### ✅ Controller Fields in machines Table
|
||||
- controllertypeid (FK → controllertypes)
|
||||
- controllerosid (FK → operatingsystems)
|
||||
- Same operatingsystems table used for both PC OS and Controller OS
|
||||
- `pc` → Use `machines WHERE pctypeid IS NOT NULL`
|
||||
- `pc_network_interfaces` → Use `communications`
|
||||
- `pc_comm_config` → Use `communications`
|
||||
- `pc_dualpath_assignments` → Use `machinerelationships`
|
||||
- `pcstatus` → Use `machinestatus`
|
||||
|
||||
### ✅ Machine Relationships
|
||||
- Dualpath: Machines sharing controller
|
||||
- Controlled By: PC controlling machine
|
||||
- Future: Clusters, backups, master-slave, etc.
|
||||
|
||||
### ✅ VLAN in JSON
|
||||
Stored in communications.settings instead of dedicated column.
|
||||
|
||||
### ✅ MFT Field
|
||||
Added to compliance table for Managed File Transfer tracking.
|
||||
|
||||
### ✅ Simplified Warranties
|
||||
Just warrantyname and enddate - minimal approach.
|
||||
|
||||
### ✅ Liaison in businessunits
|
||||
No separate liaisons table - added directly to businessunits.
|
||||
**Recommendation:** Drop after 30 days of stable operation
|
||||
|
||||
---
|
||||
|
||||
## Migration Volumes (Estimated)
|
||||
## Related Documentation
|
||||
|
||||
- machines: 543 total (266 existing + 277 from PCs)
|
||||
- communications: ~650+ records
|
||||
- warranties: ~277+ records
|
||||
- compliance: TBD (from inventory.xlsx import)
|
||||
- compliancescans: TBD (ongoing logging)
|
||||
- machinerelationships: ~50+ (dualpath pairs + PC controllers)
|
||||
- [DATABASE_MIGRATION_FINAL_DESIGN.md](DATABASE_MIGRATION_FINAL_DESIGN.md) - Phase 1 spec
|
||||
- [PC_MACHINES_CONSOLIDATION_PLAN.md](PC_MACHINES_CONSOLIDATION_PLAN.md) - Phase 2 plan
|
||||
- [PHASE3_NETWORK_DEVICES_MIGRATION_PLAN.md](PHASE3_NETWORK_DEVICES_MIGRATION_PLAN.md) - Phase 3 plan
|
||||
- [MIGRATION_QUICK_REFERENCE.md](MIGRATION_QUICK_REFERENCE.md) - Quick lookup
|
||||
|
||||
---
|
||||
|
||||
## Questions to Revisit (Optional)
|
||||
|
||||
None currently - all design decisions finalized!
|
||||
|
||||
---
|
||||
|
||||
## Session Notes
|
||||
|
||||
**What was accomplished:**
|
||||
- Designed 7 new tables
|
||||
- Extended 2 existing tables
|
||||
- Achieved 100% inventory.xlsx coverage
|
||||
- Documented machine relationships pattern
|
||||
- Finalized controller field approach
|
||||
- Created comprehensive documentation
|
||||
|
||||
**Ready for:**
|
||||
- Phase 1 SQL script creation
|
||||
- Dev environment testing
|
||||
- Data migration planning
|
||||
|
||||
---
|
||||
|
||||
**Status:** Ready to proceed with implementation whenever you're ready!
|
||||
|
||||
**Last Updated:** 2025-11-06 (End of design session)
|
||||
**Last Updated:** 2025-11-25
|
||||
|
||||
Reference in New Issue
Block a user