
#########
Migration
#########


****
NAME
****


Kernel::System::SysConfig::Migration - System configuration settings migration tools.


****************
PUBLIC INTERFACE
****************


new()
=====


Create an object. Do not use it directly, instead use:


.. code-block:: perl

     use Kernel::System::ObjectManager;
     local $Kernel::OM = Kernel::System::ObjectManager->new();
     my $SysConfigMigrationObject = $Kernel::OM->Get('Kernel::System::SysConfig::Migration');



MigrateSysConfigSettings()
==========================


Migrates config values from old SysConfig name to a new and updates modified settings with new values if needed.
The values are taken from a backed up ZZZAAuto.pm which contains the old config.

# Rename


.. code-block:: perl

     # changed 'Znuny4OTRSDatabaseBackend###Export###CSV###Separator' to 'DBCRUD###Export###CSV###Separator'
     my $Success = $SysConfigMigrationObject->MigrateSysConfigSettings(
         FilePath  => '/opt/znuny/Kernel/Config/Files/ZZZAAuto.pm',
         FileClass => 'Kernel::Config::Files::ZZZAAuto',
         Data      => {
             'Znuny4OTRSDatabaseBackend###Export###CSV###Separator' => {
                 UpdateName => 'DBCRUD###Export###CSV###Separator',
             },
         }
     );


# String


.. code-block:: perl

     my $Success = $SysConfigMigrationObject->MigrateSysConfigSettings(
         Data => {
             'Ticket::Hook' => {
                 UpdateEffectiveValue => {
                     'Ticket#' => 'Znuny###',
                 },
             }
         }
     );


# Array


.. code-block:: perl

     # Added EffectiveValue, updated old version to new and delete an old EffectiveValue.
     my $Success = $SysConfigMigrationObject->MigrateSysConfigSettings(
         Data => {
             'Loader::Agent::CommonJS###000-Framework' => {
                 AddEffectiveValue => [
                     'thirdparty/canvg-1.4/canvg.js',
                 ],
                 UpdateEffectiveValue => {
                     'thirdparty/jquery-jstree-3.3.4/jquery.jstree.js' => 'thirdparty/jquery-jstree-3.3.7/jquery.jstree.js',
                     'thirdparty/jquery-3.2.1/jquery.js'               => 'thirdparty/jquery-3.5.1/jquery.js',
                 },
                 DeleteEffectiveValue => [
                     'thirdparty/jquery-3.4.1/jquery.js',
                 ]
             }
         }
     );
 
     # OR
 
     # Set EffectiveValue
     my $Success = $SysConfigMigrationObject->MigrateSysConfigSettings(
         Data => {
             'Loader::Agent::CommonJS###000-Framework' => {
                 EffectiveValue => [
                     'thirdparty/canvg-1.4/canvg.js',
                 ],
             }
         }
     );


# Hash


.. code-block:: perl

     # Added EffectiveValue, updated old version to new and delete an old EffectiveValue.
     my $Success = $SysConfigMigrationObject->MigrateSysConfigSettings(
         Data => {
             'Ticket::InvalidOwner::StateChange' => {
                 AddEffectiveValue => {
                     'open' => 'open',
                 },
                 UpdateEffectiveValue => {
                     'pending reminder' => {
                         Key   => 'new reminder',
                         Value => 'reminder',
                     },
                 },
                 DeleteEffectiveValue => [
                     'pending auto',
                 ]
             }
         }
     );


Returns:


.. code-block:: perl

     my $Success = 1;




