-- =====================================================
-- SCRIPT 06: Extend Businessunits Table
-- =====================================================
-- Date: 2025-11-06
-- Purpose: Add liaison information to businessunits table
-- Status: REVERSIBLE (see ROLLBACK_06)
-- Estimated Time: 1 minute
-- =====================================================

USE shopdb;
SET SQL_SAFE_UPDATES = 0;

-- =====================================================
-- STEP 1: Add liaison fields
-- =====================================================

ALTER TABLE businessunits
ADD COLUMN liaisonname VARCHAR(100) AFTER businessunit,
ADD COLUMN liaisonsso VARCHAR(50) AFTER liaisonname;

-- =====================================================
-- STEP 2: Create indexes
-- =====================================================

CREATE INDEX idx_businessunits_liaisonsso ON businessunits(liaisonsso);

-- =====================================================
-- VERIFICATION
-- =====================================================

SELECT '✓ businessunits table extended' AS status;
DESCRIBE businessunits;

SELECT '✓ Script 06 completed successfully' AS status;

SET SQL_SAFE_UPDATES = 1;

-- =====================================================
-- NOTES
-- =====================================================
-- Next: Run script 07_rename_pcstatus_to_machinestatus.sql
-- Rollback: Run ROLLBACK_06_businessunits_extensions.sql
--
-- Data Migration Source (from inventory.xlsx):
-- - Column 27 "Liaison" → liaisonname + liaisonsso
--   (Parse "Name (SSO)" format)
-- =====================================================
