- Strip emojis from 47 markdown files across docs/, sql/, and root - Add docs/DOCS_CONSOLIDATION_PLAN.md with plan to reduce 45 docs to 8 - Establish no-emoji rule for documentation going forward 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
292 lines
10 KiB
Markdown
292 lines
10 KiB
Markdown
# Database Schema Comparison Report
|
||
|
||
**Date:** 2025-11-20
|
||
**Comparison:** database-backup-11-20-25-eod-with-drop.sql vs Current Dev Database
|
||
**Dev Backup Created:** /home/camp/projects/windows/shopdb/sql/dev-backup-20251120-105614.sql
|
||
|
||
---
|
||
|
||
## Executive Summary
|
||
|
||
The backup file contains **Phase 1 schema** (pre-migration) with 63 tables, while the current dev database contains **Phase 2 schema** (post-migration) with 30 tables.
|
||
|
||
**Key Findings:**
|
||
- **4 tables have schema changes** (businessunits, controllertypes, machine_overrides, machines)
|
||
- **8 new Phase 2 tables** exist in dev but not in backup
|
||
- **41 legacy tables** exist in backup but not in dev (deprecated/views)
|
||
|
||
---
|
||
|
||
## Tables Requiring DROP and Recreate
|
||
|
||
### 1. Tables with Schema Changes (4 tables)
|
||
|
||
These tables exist in both files but have different column structures. They should be **dropped and recreated** from the backup file if you want to revert to the backup schema.
|
||
|
||
#### `machines` (CRITICAL - Most Changes)
|
||
|
||
**Columns Removed in Dev (exist in backup):**
|
||
- `ipaddress1` - Removed (now in communications table)
|
||
- `ipaddress2` - Removed (now in communications table)
|
||
|
||
**Columns Added in Dev (not in backup):**
|
||
- `hostname` - For PC hostnames
|
||
- `serialnumber` - Equipment serial numbers
|
||
- `loggedinuser` - Current logged-in user (PCs)
|
||
- `pctypeid` - Identifies PCs (NULL = equipment, NOT NULL = PC)
|
||
- `osid` - Foreign key to operatingsystems (PC OS)
|
||
- `controllertypeid` - Foreign key to controllertypes
|
||
- `controllerosid` - Controller OS (for CNCs)
|
||
- `controllermodelid` - Controller model reference
|
||
- `machinestatusid` - Replaces pcstatusid
|
||
- `lastupdated` - Auto-updated timestamp
|
||
- `requires_manual_machine_config` - Configuration flag
|
||
|
||
**Impact:** This is the core table for Phase 2 migration. Reverting will break all PC and network device functionality.
|
||
|
||
---
|
||
|
||
#### `businessunits`
|
||
|
||
**Columns Added in Dev (not in backup):**
|
||
- `liaisonname` - Liaison contact name
|
||
- `liaisonsso` - Liaison SSO
|
||
- `facility_id` - Facility identifier
|
||
- `dt_lead` - DT Lead name
|
||
- `dt_lead_sso` - DT Lead SSO
|
||
|
||
**Impact:** Minor. These are additional metadata fields that don't affect core functionality.
|
||
|
||
---
|
||
|
||
#### `controllertypes`
|
||
|
||
**Columns Added in Dev (not in backup):**
|
||
- `vendorid` - Foreign key to vendors
|
||
- `controllermodel` - Controller model name
|
||
- `controller_os` - Controller OS name
|
||
- `controllernotes` - Additional notes
|
||
|
||
**Impact:** Minor. Enhanced metadata for CNC controllers.
|
||
|
||
---
|
||
|
||
#### `machine_overrides`
|
||
|
||
**Issue:** Same columns but definition differences (likely data types or constraints changed)
|
||
|
||
**Impact:** Unknown without detailed field-by-field comparison.
|
||
|
||
---
|
||
|
||
## New Tables in Dev (Phase 2 Migration)
|
||
|
||
These 8 tables exist in the current dev database but NOT in the backup file. They are **Phase 2 migration tables** and should be **preserved**.
|
||
|
||
### Phase 2 Tables (DO NOT DROP)
|
||
|
||
1. **`communications`** - Unified network interface storage (replaces pc_network_interfaces, printer IPs)
|
||
2. **`comstypes`** - Communication types (IP, Serial, USB, etc.)
|
||
3. **`compliance`** - Compliance tracking data
|
||
4. **`compliancescans`** - Compliance scan history
|
||
5. **`machinerelationships`** - Machine-to-machine relationships (dualpath, controls)
|
||
6. **`relationshiptypes`** - Relationship type definitions
|
||
7. **`machinestatus`** - Replaces pcstatus with broader scope
|
||
8. **`warranties`** - Warranty tracking
|
||
|
||
**These tables are critical for Phase 2 functionality and should NOT be dropped.**
|
||
|
||
---
|
||
|
||
## Legacy Tables in Backup (Not in Dev)
|
||
|
||
These 41 tables exist in the backup file but NOT in the current dev database. Most are **deprecated** or **views**.
|
||
|
||
### Deprecated PC Tables (Replaced by machines + communications)
|
||
|
||
- `pc` - **DEPRECATED** → Replaced by machines WHERE pctypeid IS NOT NULL
|
||
- `pc_network_interfaces` - **DEPRECATED** → Replaced by communications
|
||
- `pc_comm_config` - **DEPRECATED** → Replaced by communications
|
||
- `pc_dnc_config` - **DEPRECATED** → Integrated into machine relationships
|
||
- `pc_dualpath_assignments` - **DEPRECATED** → Replaced by machinerelationships
|
||
- `pctype` - **DEPRECATED** → Now stored in machines.pctypeid
|
||
- `pcstatus` - **DEPRECATED** → Replaced by machinestatus
|
||
|
||
### Deprecated Network Device Tables (Replaced by machines)
|
||
|
||
- `accesspoints` - **DEPRECATED** → Replaced by machines WHERE machinetypeid = 16
|
||
- `cameras` - **DEPRECATED** → Replaced by machines WHERE machinetypeid = 18
|
||
- `switches` - **DEPRECATED** → Replaced by machines WHERE machinetypeid = 19
|
||
- `servers` - **DEPRECATED** → Replaced by machines WHERE machinetypeid = 20
|
||
- `idfs` - **DEPRECATED** → Replaced by machines WHERE machinetypeid = 17
|
||
|
||
### Legacy Relationship Table
|
||
|
||
- `machine_pc_relationships` - **DEPRECATED** → Replaced by machinerelationships
|
||
|
||
### Backup Table
|
||
|
||
- `pc_model_backup` - Backup table (can be dropped)
|
||
|
||
### Views (33 views)
|
||
|
||
All views with `vw_` prefix are query views, not base tables:
|
||
|
||
- `vw_active_pcs`
|
||
- `vw_dnc_config`
|
||
- `vw_dualpath_management`
|
||
- `vw_engineer_pcs`
|
||
- `vw_ge_machines`
|
||
- `vw_idf_inventory`
|
||
- `vw_infrastructure_summary`
|
||
- `vw_machine_assignments`
|
||
- `vw_machine_assignment_status`
|
||
- `vw_machinetype_comparison`
|
||
- `vw_machine_type_stats`
|
||
- `vw_multi_pc_machines`
|
||
- `vw_network_devices`
|
||
- `vw_pc_network_summary`
|
||
- `vw_pc_resolved_machines`
|
||
- `vw_pcs_by_hardware`
|
||
- `vw_pc_summary`
|
||
- `vw_pctype_config`
|
||
- `vw_recent_updates`
|
||
- `vw_shopfloor_applications_summary`
|
||
- `vw_shopfloor_comm_config`
|
||
- `vw_shopfloor_pcs`
|
||
- `vw_standard_pcs`
|
||
- `vw_unmapped_machines`
|
||
- `vw_vendor_summary`
|
||
- `vw_warranties_expiring`
|
||
- `vw_warranty_status`
|
||
|
||
**Note:** Views need to be recreated to match Phase 2 schema.
|
||
|
||
---
|
||
|
||
## Recommendation: What to Drop and Recreate
|
||
|
||
### CRITICAL WARNING
|
||
|
||
**DO NOT apply the backup file schema if you want to keep Phase 2 functionality!**
|
||
|
||
The backup file represents the **OLD Phase 1 schema** before the major PC migration work completed on Nov 17, 2025. Applying it would:
|
||
|
||
1. Lose all Phase 2 migration work (20+ days of development)
|
||
2. Break all PC pages (displaypcs.asp, displaypc.asp, editpc.asp, etc.)
|
||
3. Break network device display (network_map.asp, network_devices.asp)
|
||
4. Lose unified communications table
|
||
5. Lose machine relationships functionality
|
||
6. Lose compliance tracking
|
||
7. Lose warranty management
|
||
|
||
### If You Must Revert to Backup Schema
|
||
|
||
**Tables to DROP and recreate from backup:**
|
||
|
||
1. `machines` - DROP and recreate (loses Phase 2 columns)
|
||
2. `businessunits` - DROP and recreate (loses liaison/facility fields)
|
||
3. `controllertypes` - DROP and recreate (loses enhanced metadata)
|
||
4. `machine_overrides` - DROP and recreate (definition changes)
|
||
|
||
**Tables to DROP from dev (Phase 2 tables):**
|
||
|
||
5. `communications` - DROP (then recreate from backup if needed)
|
||
6. `comstypes` - DROP
|
||
7. `compliance` - DROP
|
||
8. `compliancescans` - DROP
|
||
9. `machinerelationships` - DROP
|
||
10. `relationshiptypes` - DROP
|
||
11. `machinestatus` - DROP (will recreate `pcstatus` from backup)
|
||
12. `warranties` - DROP
|
||
|
||
**Tables to ADD from backup (legacy tables):**
|
||
|
||
13. ➕ `pc` - CREATE from backup
|
||
14. ➕ `pc_network_interfaces` - CREATE from backup
|
||
15. ➕ `pc_comm_config` - CREATE from backup
|
||
16. ➕ `pc_dnc_config` - CREATE from backup
|
||
17. ➕ `pc_dualpath_assignments` - CREATE from backup
|
||
18. ➕ `pctype` - CREATE from backup
|
||
19. ➕ `pcstatus` - CREATE from backup
|
||
20. ➕ `accesspoints` - CREATE from backup (if needed)
|
||
21. ➕ `cameras` - CREATE from backup (if needed)
|
||
22. ➕ `switches` - CREATE from backup (if needed)
|
||
23. ➕ `servers` - CREATE from backup (if needed)
|
||
24. ➕ `idfs` - CREATE from backup (if needed)
|
||
25. ➕ `machine_pc_relationships` - CREATE from backup
|
||
|
||
**Views to recreate (33 views):** All `vw_*` views need to be dropped and recreated from backup.
|
||
|
||
---
|
||
|
||
## Recommended Action Plan
|
||
|
||
### Option 1: Keep Phase 2 Schema (RECOMMENDED)
|
||
|
||
**DO NOTHING.** Your current dev database is the latest Phase 2 schema with all improvements.
|
||
|
||
The backup file is outdated and should not be applied unless you need to revert Phase 2 changes.
|
||
|
||
### Option 2: Sync Backup File to Match Dev
|
||
|
||
If the backup file is supposed to be the "source of truth", then UPDATE the backup file to include Phase 2 schema:
|
||
|
||
1. Export current dev schema: `mysqldump shopdb > new-phase2-backup.sql`
|
||
2. Replace old backup file with Phase 2 schema
|
||
3. Use Phase 2 schema for future deployments
|
||
|
||
### Option 3: Revert to Backup Schema (NOT RECOMMENDED)
|
||
|
||
If you absolutely must revert to Phase 1 schema:
|
||
|
||
1. Backup current dev database (already done: dev-backup-20251120-105614.sql)
|
||
2. Drop Phase 2 tables: communications, compliance, machinerelationships, etc.
|
||
3. Restore machines, businessunits, controllertypes to backup versions
|
||
4. Restore all legacy tables (pc, pc_network_interfaces, etc.)
|
||
5. Recreate all views
|
||
6. **Accept that all Phase 2 functionality will be lost**
|
||
|
||
---
|
||
|
||
## Table Count Summary
|
||
|
||
| Category | Backup File | Dev Database | Difference |
|
||
|----------|-------------|--------------|------------|
|
||
| **Total Tables** | 63 | 30 | -33 |
|
||
| **Base Tables** | 36 | 30 | -6 |
|
||
| **Views** | 27 | 0 | -27 |
|
||
| **Schema Changes** | - | 4 | - |
|
||
| **New in Dev** | - | 8 | +8 |
|
||
| **Missing in Dev** | 41 | - | - |
|
||
|
||
---
|
||
|
||
## Files Generated
|
||
|
||
1. **Current Dev Backup:** `/home/camp/projects/windows/shopdb/sql/dev-backup-20251120-105614.sql` (464 KB)
|
||
2. **This Report:** `/home/camp/projects/windows/shopdb/SCHEMA_COMPARISON_REPORT_2025-11-20.md`
|
||
|
||
---
|
||
|
||
## Conclusion
|
||
|
||
**The backup file (database-backup-11-20-25-eod-with-drop.sql) is from BEFORE Phase 2 migration.**
|
||
|
||
Your current dev database has the **Phase 2 schema** with significant improvements:
|
||
- Unified machines table for all infrastructure
|
||
- Consolidated communications table
|
||
- Machine relationships tracking
|
||
- Compliance management
|
||
- Warranty tracking
|
||
|
||
**Recommendation:** Do NOT apply the backup file schema. Keep your current Phase 2 dev schema.
|
||
|
||
If production needs updating, use your current dev schema as the source, not the backup file.
|
||
|
||
---
|
||
|
||
**Generated:** 2025-11-20 10:56
|
||
**Analyst:** Claude Code
|
||
**Status:** Analysis Complete
|