RotherOSS / ITSMConfigurationManagement

This package implements all ITSM configuration management features. This package requires the ITSMCore package.
GNU General Public License v3.0
0 stars 1 forks source link

[BUG] Upgrade CMDB from 10 to 11. #26

Open laiminhtrung1997 opened 1 week ago

laiminhtrung1997 commented 1 week ago
otobo@otobo-0:~$ perl "$OTOBO_HOME/bin/otobo.Console.pl" Admin::ITSM::Configitem::UpgradeTo11 --use-defaults
Starting CMDB upgrade!

~~ Step 0 ~~
Start working on Prepare Attribute Mapping
Writing attribute maps into /opt/otobo/var/tmp/CMDBUpgradeTo11Schemata

~~ Step 1 ~~
Start working on Prepare Definitions
Writing class definitions.

~~ Step 2 ~~
Start working on Migrate Definitions
Import definitions.
DBD::Pg::db do failed: ERROR:  type "longblob" does not exist
LINE 1: ..._definition ADD COLUMN configitem_definition_legacy longblob
                                                               ^ at /opt/otobo/Kernel/System/DB.pm line 586.
ERROR: OTOBO-otobo.Console.pl-Admin::ITSM::Configitem::UpgradeTo11-10 Perl: 5.38.2 OS: linux Time: Thu Nov 14 10:50:27 2024

 Message: ERROR:  type "longblob" does not exist
LINE 1: ..._definition ADD COLUMN configitem_definition_legacy longblob
                                                               ^, SQL: 'ALTER TABLE configitem_definition ADD COLUMN configitem_definition_legacy longblob'

 Traceback (29): 
   Module: Kernel::System::Console::Command::Admin::ITSM::Configitem::UpgradeTo11::_MigrateDefinitions Line: 375
   Module: Kernel::System::Console::Command::Admin::ITSM::Configitem::UpgradeTo11::Run Line: 181
   Module: (eval) Line: 488
   Module: Kernel::System::Console::BaseCommand::Execute Line: 482
   Module: Kernel::System::Console::InterfaceConsole::Run Line: 88
   Module: /opt/otobo/bin/otobo.Console.pl Line: 40

Could not clone the configitem_definition column DB table. If you attempted this step earlier, please write 'con' to continue.
        con

You already have dynamic field namespaces deployed, thus the new ones will not automatically be set. Please add them manually:
        Computer
        Hardware
        Location
        Network
        Software

~~ Step 3 ~~
Start working on Migrate Attribute Data
Copy attribute data.
        Working on Computer (0 Versions)
        Working on Hardware (0 Versions)
        Working on Location (0 Versions)
        Working on Network (0 Versions)
        Working on Software (0 Versions)

~~ Step 4 ~~
Start working on Delete Legacy Data
Optionally all legacy data can be deleted. This step is not necessary for the migrated CMDB to work and can be done at any later time.

Do you really want to permanently delete all legacy data from the system? (yes|no)
no
Continuing without deleting legacy data.
Done!

Steps:

Expected:

There are no ERRORs in the logs.

stefanhaerter commented 2 days ago

For usage with postgresql, the data type should be 'TEXT' instead of longblob, as coded here:

https://github.com/RotherOSS/otobo/blob/2560c53ab61b5df0d3c4ef219fa14811b450ca3b/Kernel/System/DB/postgresql.pm#L954-L957

rel-11_0 Kernel/System/DB/postgresql.pm, lines 954-957

    # performance option
    elsif ( $Tag->{Type} =~ /^longblob$/i ) {
        $Tag->{Type} = 'TEXT';
    }

However, if SQL is executed directly, such a type conversion does not take place. It has to be thought about where to best place a fix for this problem.

laiminhtrung1997 commented 1 day ago

Hi @stefanhaerter I customized the file UpgradeTo11.pm to text instead of longblob to temporarily handle this error. Do you have a plan to fix it?

stefanhaerter commented 1 day ago

Hi @laiminhtrung1997,

thank you for putting in the work and testing this out =) I do have a plan, which is the following: There is a SQL processor mechanism in place which receives the statement as XML and converts it to SQL which fits the used database. I am currently working on implementing usage of the respective mechanism in the console command. I am confident that I can provide it within the next days.

laiminhtrung1997 commented 1 day ago

@stefanhaerter Thank you once again. Can not wait to see that.

stefanhaerter commented 1 hour ago

Fix is tested (on MariaDB and PostgreSQL) and will as well be included into the next release.