From e2e7cb146657fbf6b0ddd2dd230d6a523a9a3792 Mon Sep 17 00:00:00 2001 From: cproudlock Date: Mon, 8 Dec 2025 15:33:08 -0500 Subject: [PATCH] Consolidate PC types: use pctypeid instead of multiple machinetypeids MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All PCs now use machinetypeid 33 (PC) with pctypeid for sub-type: - Standard, Engineer, Shopfloor, CMM, Wax/Trace, Keyence, Genspect, Heat Treat Added new pctypes: Keyence, Genspect, Heat Treat 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- sql/consolidate_pc_machinetypes.sql | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 sql/consolidate_pc_machinetypes.sql diff --git a/sql/consolidate_pc_machinetypes.sql b/sql/consolidate_pc_machinetypes.sql new file mode 100644 index 0000000..ef838f4 --- /dev/null +++ b/sql/consolidate_pc_machinetypes.sql @@ -0,0 +1,44 @@ +-- Consolidate PC Machine Types +-- Date: 2025-12-08 +-- +-- Previously PCs used multiple machinetypeids: +-- 33: Standard PC +-- 34: Engineering PC +-- 35: Shopfloor PC +-- 42: PC - Wax Trace +-- 43: PC - Measuring Tool +-- +-- Now all PCs use machinetypeid 33 (PC) with pctypeid for sub-type + +-- Add new PC types +INSERT IGNORE INTO pctype (typename, description, functionalaccountid, isactive, displayorder) VALUES +('Keyence', 'Keyence measurement system', 1, 1, 6), +('Genspect', 'Genspect inspection system', 1, 1, 7), +('Heat Treat', 'Heat treat monitoring', 1, 1, 8); + +-- Rename machinetypeid 33 to just 'PC' +UPDATE machinetypes SET machinetype = 'PC' WHERE machinetypeid = 33; + +-- Update pctypeid based on current machinetypeid +-- 34 (Engineering PC) -> pctypeid 2 (Engineer) +UPDATE machines SET pctypeid = 2 WHERE machinetypeid = 34 AND (pctypeid IS NULL OR pctypeid = 1); + +-- 35 (Shopfloor PC) -> pctypeid 3 (Shopfloor) +UPDATE machines SET pctypeid = 3 WHERE machinetypeid = 35 AND (pctypeid IS NULL OR pctypeid = 1); + +-- 42 (PC - Wax Trace) -> pctypeid 6 (Wax / Trace) +UPDATE machines SET pctypeid = 6 WHERE machinetypeid = 42 AND (pctypeid IS NULL OR pctypeid = 1); + +-- 43 (PC - Measuring Tool) -> pctypeid 7 (Keyence) +UPDATE machines SET pctypeid = 7 WHERE machinetypeid = 43 AND (pctypeid IS NULL OR pctypeid = 1); + +-- Consolidate all PCs to machinetypeid 33 +UPDATE machines SET machinetypeid = 33 WHERE machinetypeid IN (34, 35, 42, 43); + +-- Verification query +-- SELECT pt.pctypeid, pt.typename, COUNT(*) as count +-- FROM machines m +-- JOIN pctype pt ON m.pctypeid = pt.pctypeid +-- WHERE m.pctypeid IS NOT NULL +-- GROUP BY pt.pctypeid, pt.typename +-- ORDER BY pt.pctypeid;