Fix ednc_tables.sql - fresh table creation (not migration)
Production doesn't have the table yet, so create it fresh with machineid schema from the start. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,25 +1,23 @@
|
|||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
-- eDNC Special Character Fix - Database Migration
|
-- eDNC Special Character Fix - Database Setup
|
||||||
-- Migrates ednclogs from hostname to machineid (FK to machines table)
|
-- Run on PRODUCTION to create ednclogs table
|
||||||
-- Run on PRODUCTION after initial setup
|
-- Created: 2025-12-12
|
||||||
-- Updated: 2025-12-12
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
|
|
||||||
-- Step 1: Add machineid column to ednclogs
|
-- Create ednclogs table (uses machineid FK to machines table)
|
||||||
ALTER TABLE ednclogs
|
CREATE TABLE IF NOT EXISTS ednclogs (
|
||||||
ADD COLUMN machineid INT NOT NULL AFTER logid,
|
logid INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
ADD INDEX idx_machineid (machineid);
|
machineid INT NOT NULL,
|
||||||
|
filename VARCHAR(255) NOT NULL,
|
||||||
|
action ENUM('cleaned', 'ok', 'failed', 'error', 'started', 'stopped') NOT NULL,
|
||||||
|
bytes_removed INT DEFAULT 0,
|
||||||
|
version VARCHAR(20),
|
||||||
|
message VARCHAR(500),
|
||||||
|
created DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
INDEX idx_machineid (machineid),
|
||||||
|
INDEX idx_created (created),
|
||||||
|
INDEX idx_action (action)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
-- Step 2: Populate machineid from hostname (match existing PCs)
|
-- Verify
|
||||||
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;
|
DESCRIBE ednclogs;
|
||||||
|
|||||||
Reference in New Issue
Block a user