Files
shopdb/sql/ednc_tables.sql
cproudlock a1a10a51d2 eDNC: Use machineid instead of hostname for proper FK relationship
- ednclogs table now uses machineid to link to machines table
- Removed redundant hostname storage (derive from machines table)
- Updated LogDNCEvent to look up and insert machineid
- Updated GetDNCStats to join machines table for hostname
- Updated displaypc.asp queries to use machineid directly
- sql/ednc_tables.sql is now a migration script for existing production

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 09:33:27 -05:00

26 lines
941 B
SQL

-- ============================================================================
-- eDNC Special Character Fix - Database Migration
-- Migrates ednclogs from hostname to machineid (FK to machines table)
-- Run on PRODUCTION after initial setup
-- Updated: 2025-12-12
-- ============================================================================
-- Step 1: Add machineid column to ednclogs
ALTER TABLE ednclogs
ADD COLUMN machineid INT NOT NULL AFTER logid,
ADD INDEX idx_machineid (machineid);
-- Step 2: Populate machineid from hostname (match existing PCs)
UPDATE ednclogs l
INNER JOIN machines m ON UPPER(m.hostname) = UPPER(l.hostname)
SET l.machineid = m.machineid
WHERE m.pctypeid IS NOT NULL;
-- Step 3: Remove hostname column and index
ALTER TABLE ednclogs DROP INDEX idx_hostname;
ALTER TABLE ednclogs DROP COLUMN hostname;
-- Verify migration
SELECT 'Migration complete' AS status;
DESCRIBE ednclogs;