znuny / Znuny

Znuny/Znuny LTS is a fork of the ((OTRS)) Community Edition, one of the most flexible web-based ticketing systems used for Customer Service, Help Desk, IT Service Management.
https://www.znuny.org
GNU General Public License v3.0
335 stars 82 forks source link

scripts/MigrateToZnuny6_5.pl -- Missing fields in tables #452

Closed fxlxx closed 1 year ago

fxlxx commented 1 year ago

Environment

Actual behaviour

https://doc.znuny.org/znuny_lts/releases/installupdate/update/update-6.5.html#

(Note: Update instructions are still for 6.5.2)

During the update process from version 6.5.1 to 6.5.3, errors occurred while executing the scripts/MigrateToZnuny6_5.pl script. However, despite the errors and creating the folder /opt/otrs/var/run after the failed first try, the migration script was successfully completed.

First try, missing folder /opt/otrs/var/run

otrs@lxtts:~$ scripts/MigrateToZnuny6_5.pl

 Migration started ... 

 Checking requirements ... 

    Requirement check for: Check required Perl version ...
    Requirement check for: Check required database version ...
    Requirement check for: Check database charset ...
    Requirement check for: Check required Perl modules ...
    Requirement check for: Check if database has been backed up ...

        Did you backup the database? [Y]es/[N]o: Y

    Requirement check for: Migrate SysConfig settings ...

        Should the SysConfig be migrated? [Y]es/[N]o: Y

 Executing tasks ... 

    Step 1 of 18: Check required Perl version ...
    Step 2 of 18: Check required database version ...
    Step 3 of 18: Check database charset ...
    Step 4 of 18: Check required Perl modules ...
    Step 5 of 18: Check if database has been backed up ...
    Step 6 of 18: Rebuild configuration ...
    Step 7 of 18: Migrate SysConfig settings ...
ERROR: MigrateToZnuny6_5.pl-10 Perl: 5.28.1 OS: linux Time: Sat Jun 24 09:58:59 2023

 Message: Setting Daemon::PID::Path Effective value is not correct: /opt/otrs/var/run/ not exists!

 Traceback (18905): 
   Module: Kernel::System::SysConfig::ConfigurationDeploy Line: 3488
   Module: Kernel::System::SysConfig::SettingsSet Line: 4742
   Module: Kernel::System::SysConfig::Migration::MigrateSysConfigSettings Line: 367
   Module: scripts::Migration::Znuny::MigrateSysConfigSettings::Run Line: 224
   Module: scripts::Migration::_ExecuteComponent Line: 167
   Module: scripts::Migration::Run Line: 77
   Module: scripts/MigrateToZnuny6_5.pl Line: 82

    Step 8 of 18: Migrate DBCRUD UUID columns ...
        Calendar::Plugin: Column dbcrud_uuid in table calendar_appointment_plugin...
            Column already exists
        OAuth2Token: Column dbcrud_uuid in table oauth2_token...
            Column already exists
        OAuth2TokenConfig: Column dbcrud_uuid in table oauth2_token_config...
            Column already exists
    Step 9 of 18: Migrate dynamic fields ...
    Step 10 of 18: Migrate notification events ...
    Step 11 of 18: Integrate Znuny-NoteToLinkedTicket ...
ERROR: MigrateToZnuny6_5.pl-10 Perl: 5.28.1 OS: linux Time: Sat Jun 24 09:59:00 2023

 Message: Setting Daemon::PID::Path Effective value is not correct: /opt/otrs/var/run/ not exists!

 Traceback (18905): 
   Module: Kernel::System::SysConfig::ConfigurationDeploy Line: 3488
   Module: Kernel::System::SysConfig::SettingsSet Line: 4742
   Module: scripts::Migration::Znuny::IntegrateZnunyNoteToLinkedTicket::_ArticleActionConfigAdd Line: 60
   Module: scripts::Migration::Znuny::IntegrateZnunyNoteToLinkedTicket::Run Line: 33
   Module: scripts::Migration::_ExecuteComponent Line: 167
   Module: scripts::Migration::Run Line: 77
   Module: scripts/MigrateToZnuny6_5.pl Line: 82

 Not possible to complete migration. Check previous messages for more information.

Created the folder /opt/otrs/var/run and run script a second time:

otrs@lxtts:~$ scripts/MigrateToZnuny6_5.pl

 Migration started ... 

 Checking requirements ... 

    Requirement check for: Check required Perl version ...
    Requirement check for: Check required database version ...
    Requirement check for: Check database charset ...
    Requirement check for: Check required Perl modules ...
    Requirement check for: Check if database has been backed up ...

        Did you backup the database? [Y]es/[N]o: Y

    Requirement check for: Migrate SysConfig settings ...

        Should the SysConfig be migrated? [Y]es/[N]o: Y

 Executing tasks ... 

    Step 1 of 18: Check required Perl version ...
    Step 2 of 18: Check required database version ...
    Step 3 of 18: Check database charset ...
    Step 4 of 18: Check required Perl modules ...
    Step 5 of 18: Check if database has been backed up ...
    Step 6 of 18: Rebuild configuration ...
    Step 7 of 18: Migrate SysConfig settings ...
    Step 8 of 18: Migrate DBCRUD UUID columns ...
        Calendar::Plugin: Column dbcrud_uuid in table calendar_appointment_plugin...
            Column already exists
        OAuth2Token: Column dbcrud_uuid in table oauth2_token...
            Column already exists
        OAuth2TokenConfig: Column dbcrud_uuid in table oauth2_token_config...
            Column already exists
    Step 9 of 18: Migrate dynamic fields ...
    Step 10 of 18: Migrate notification events ...
    Step 11 of 18: Integrate Znuny-NoteToLinkedTicket ...
    Step 12 of 18: Uninstall merged packages ...
    Step 13 of 18: Initialize default cron jobs ...
    Copying /opt/otrs/var/cron/aaa_base.dist to /opt/otrs/var/cron/aaa_base...
    done.
    Copying /opt/otrs/var/cron/otrs_daemon.dist to /opt/otrs/var/cron/otrs_daemon...
    done.
    Step 14 of 18: Clean up the cache ...
    Step 15 of 18: Rebuild configuration another time ...
    Step 16 of 18: Deploy ACLs ...
    Step 17 of 18: Deploy processes ...
    Step 18 of 18: Check invalid settings ...

 Migration completed! 

From /var/log/syslog :

Jun 24 10:21:55 lxtts MigrateToZnuny6_5.pl-10[20637]: [Error][Kernel::System::DBCRUD::MigrateUUIDDatabaseTableColumns][Line:1828]: Unknown column 'z4o_database_backend_uuid' in 'field list', SQL: 'SELECT z4o_database_backend_uuid FROM calendar_appointment_plugin LIMIT 1'
Jun 24 10:21:55 lxtts MigrateToZnuny6_5.pl-10[20637]: [Error][Kernel::System::DBCRUD::MigrateUUIDDatabaseTableColumns][Line:1828]: Unknown column 'database_backend_uuid' in 'field list', SQL: 'SELECT database_backend_uuid FROM calendar_appointment_plugin LIMIT 1'
Jun 24 10:21:55 lxtts MigrateToZnuny6_5.pl-10[20637]: [Error][Kernel::System::DBCRUD::MigrateUUIDDatabaseTableColumns][Line:1828]: Unknown column 'z4o_database_backend_uuid' in 'field list', SQL: 'SELECT z4o_database_backend_uuid FROM oauth2_token LIMIT 1'
Jun 24 10:21:55 lxtts MigrateToZnuny6_5.pl-10[20637]: [Error][Kernel::System::DBCRUD::MigrateUUIDDatabaseTableColumns][Line:1828]: Unknown column 'database_backend_uuid' in 'field list', SQL: 'SELECT database_backend_uuid FROM oauth2_token LIMIT 1'
Jun 24 10:21:55 lxtts MigrateToZnuny6_5.pl-10[20637]: [Error][Kernel::System::DBCRUD::MigrateUUIDDatabaseTableColumns][Line:1828]: Unknown column 'z4o_database_backend_uuid' in 'field list', SQL: 'SELECT z4o_database_backend_uuid FROM oauth2_token_config LIMIT 1'
Jun 24 10:21:55 lxtts MigrateToZnuny6_5.pl-10[20637]: [Error][Kernel::System::DBCRUD::MigrateUUIDDatabaseTableColumns][Line:1828]: Unknown column 'database_backend_uuid' in 'field list', SQL: 'SELECT database_backend_uuid FROM oauth2_token_config LIMIT 1'

Checking the tables the fields do indeed not exist (example oauth2_token)

MariaDB [otrs2]> describe oauth2_token;
+-------------------------------+-------------+------+-----+---------+----------------+
| Field                         | Type        | Null | Key | Default | Extra          |
+-------------------------------+-------------+------+-----+---------+----------------+
| id                            | int(11)     | NO   | PRI | NULL    | auto_increment |
| token_config_id               | int(11)     | NO   | UNI | NULL    |                |
| authorization_code            | mediumtext  | YES  |     | NULL    |                |
| token                         | mediumtext  | YES  |     | NULL    |                |
| token_expiration_date         | datetime    | YES  |     | NULL    |                |
| refresh_token                 | mediumtext  | YES  |     | NULL    |                |
| refresh_token_expiration_date | datetime    | YES  |     | NULL    |                |
| error_message                 | mediumtext  | YES  |     | NULL    |                |
| error_description             | mediumtext  | YES  |     | NULL    |                |
| error_code                    | text        | YES  |     | NULL    |                |
| create_time                   | datetime    | NO   |     | NULL    |                |
| create_by                     | int(11)     | NO   | MUL | NULL    |                |
| change_time                   | datetime    | NO   |     | NULL    |                |
| change_by                     | int(11)     | NO   | MUL | NULL    |                |
| dbcrud_uuid                   | varchar(36) | YES  | UNI | NULL    |                |
+-------------------------------+-------------+------+-----+---------+----------------+
15 rows in set (0.002 sec)

How to reproduce

Run upgrade process and scripts/MigrateToZnuny6_5.pl

hanneshal commented 1 year ago

Hi @fxlxx

thanks for the report. 1) Regarding the /otp/otrs path issue. I think you missed the correct setting for $HOME in you Kernel/Config.pm - could this be the case?

2) The error does only note already existing columns.

OAuth2Token: Column dbcrud_uuid in table oauth2_token... Column already exists

To explain this a bit more: The migration performs a check for certain columns from older Znuny packages and tries to migrate them. So a simple select is performed to check for them.

Like this one: Jun 24 10:21:55 lxtts MigrateToZnuny6_5.pl-10[20637]: [Error][Kernel::System::DBCRUD::MigrateUUIDDatabaseTableColumns][Line:1828]: Unknown column 'database_backend_uuid' in 'field list', SQL: 'SELECT database_backend_uuid FROM oauth2_token LIMIT 1'

The column is not known because you did not had this package installed. But, the column (with a slightly different name - we removed the z4o prefix) is already available from an earlier version. We can not find the column => No migration is necessary.

So everything is fine, except maybe your $Home path in the Config.pm

Johannes

fxlxx commented 1 year ago

Hi @hanneshal

I think you missed the correct setting for $HOME in you Kernel/Config.pm - could this be the case?

From Kernel/Config.pm

$Self->{Home} = '/opt/otrs';

This should not be the problem.