Execute naming convention fix on dev - tables renamed, ASP updated

Database changes applied:
- machine_overrides -> machineoverrides
- pc_comm_config -> commconfig
- pc_dnc_config -> dncconfig
- pc_dualpath_assignments -> dualpathassignments
- pc_network_interfaces -> networkinterfaces
- usb_checkouts -> usbcheckouts

ASP files updated (10 files):
- api.asp, api_usb.asp
- displaypc.asp, displaysubnet.asp, displaymachine.asp
- displayusb.asp, displayprofile.asp
- usb_history.asp, savecheckin_usb.asp, savecheckout_usb.asp

9 views recreated with new table references.

Tested and verified working on dev environment.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-12-10 14:59:47 -05:00
parent 946074148f
commit 30ea1bb42f
12 changed files with 46 additions and 41 deletions

View File

@@ -3,14 +3,22 @@
-- Purpose: Drop views that reference underscore tables, recreate with new names
-- Target: MySQL 5.6 (dev and production)
--
-- USAGE:
-- 1. Run Part 1 (DROP) BEFORE running 03_rename_tables.sql
-- IMPORTANT: This is a SINGLE script. Run it all at once in MySQL Workbench
-- or via mysql command line. Do NOT split it up.
--
-- USAGE ORDER:
-- 1. Run this entire script FIRST (drops old views, creates new ones)
-- 2. Then run 03_rename_tables.sql
-- 3. The views will error until tables are renamed - that's expected
--
-- OR for safer approach:
-- 1. Run just the DROP statements
-- 2. Run 03_rename_tables.sql
-- 3. Run Part 2 (CREATE) AFTER running 03_rename_tables.sql
-- 3. Run just the CREATE statements
-- ============================================================================
-- ============================================================================
-- PART 1: DROP VIEWS (run BEFORE table renames)
-- PART 1: DROP VIEWS
-- ============================================================================
DROP VIEW IF EXISTS vw_active_pcs;
@@ -23,12 +31,10 @@ DROP VIEW IF EXISTS vw_shopfloor_comm_config;
DROP VIEW IF EXISTS vw_shopfloor_pcs;
DROP VIEW IF EXISTS vw_standard_pcs;
SELECT 'Views dropped. Now run 03_rename_tables.sql, then run Part 2 below.' AS status;
-- ============================================================================
-- PART 2: RECREATE VIEWS (run AFTER table renames)
-- Note: These views now reference machineoverrides instead of machine_overrides
-- Note: pc_to_machine_id_mapping is kept for now as it's used for pcid mapping
-- PART 2: RECREATE VIEWS
-- Note: These reference the NEW table name: machineoverrides (not machine_overrides)
-- Note: pc_to_machine_id_mapping is kept for pcid->machineid mapping
-- ============================================================================
-- vw_active_pcs
@@ -241,10 +247,8 @@ ORDER BY m.hostname;
-- VERIFICATION
-- ============================================================================
SELECT 'Verifying views recreated...' AS status;
SELECT TABLE_NAME, VIEW_DEFINITION IS NOT NULL AS has_definition
FROM INFORMATION_SCHEMA.VIEWS
SELECT 'Views recreated successfully!' AS status;
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME IN (
'vw_active_pcs',
@@ -256,6 +260,5 @@ AND TABLE_NAME IN (
'vw_shopfloor_comm_config',
'vw_shopfloor_pcs',
'vw_standard_pcs'
);
SELECT 'Views recreated successfully!' AS status;
)
ORDER BY TABLE_NAME;

View File

@@ -68,7 +68,7 @@ This guide covers migrating table names from `snake_case` to `camelCase` to matc
Or use MySQL Workbench to connect.
3. **Drop dependent views (Part 1 of script 04)**
3. **Drop dependent views**
```sql
DROP VIEW IF EXISTS vw_active_pcs;
DROP VIEW IF EXISTS vw_dnc_config;
@@ -81,7 +81,7 @@ This guide covers migrating table names from `snake_case` to `camelCase` to matc
DROP VIEW IF EXISTS vw_standard_pcs;
```
4. **Rename tables (script 03)**
4. **Rename tables**
```sql
RENAME TABLE machine_overrides TO machineoverrides;
RENAME TABLE pc_comm_config TO commconfig;
@@ -91,9 +91,11 @@ This guide covers migrating table names from `snake_case` to `camelCase` to matc
RENAME TABLE usb_checkouts TO usbcheckouts;
```
5. **Recreate views (Part 2 of script 04)**
- Run the CREATE VIEW statements from `04_drop_and_recreate_views.sql`
- Can copy/paste into MySQL Workbench or run as script
5. **Recreate views**
- Open `04_drop_and_recreate_views.sql` in MySQL Workbench
- Skip the DROP statements (already done in step 3)
- Run all the CREATE VIEW statements
- Or run the entire script (DROPs will just say "view doesn't exist")
6. **Verify tables renamed**
```sql