CREATE TABLE IF NOT EXISTS vehicle_identity_oem_audit (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    vin VARCHAR(64) NOT NULL,
    before_oem VARCHAR(128) NOT NULL DEFAULT '',
    after_oem VARCHAR(128) NOT NULL,
    source_system VARCHAR(64) NOT NULL,
    source_version VARCHAR(128) NOT NULL,
    source_brand_code VARCHAR(128) NOT NULL DEFAULT '',
    source_model_name VARCHAR(255) NOT NULL DEFAULT '',
    source_updated_at DATETIME(3) NULL,
    actor VARCHAR(128) NOT NULL,
    created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    UNIQUE KEY uk_vehicle_oem_audit_version (vin, source_system, source_version),
    INDEX idx_vehicle_oem_audit_created (created_at),
    INDEX idx_vehicle_oem_audit_source (source_system, source_version)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
