RotherOSS / otobo

OTOBO is one of the most flexible web-based ticketing systems used for Customer Service, Help Desk, IT Service Management. https://otobo.io/
GNU General Public License v3.0
240 stars 72 forks source link

DBUpdate-to-11.0.pl -> Message: All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead, SQL: 'ALTER TABLE dynamic_field_value CHANGE id id BIGINT NULL' #3427

Closed smellord closed 1 month ago

smellord commented 1 month ago

I've changed the /opt/otobo/scripts/DBUpdateTo11_0/DBUpdateDynamicFieldValue.pm to fix this issue and proceed with the update:

package scripts::DBUpdateTo11_0::DBUpdateDynamicFieldValue;

use v5.24; use strict; use warnings; use utf8;

core modules

CPAN modules

OTOBO modules

our @ObjectDependencies = ( 'Kernel::System::DB', 'Kernel::System::Log', );

=head1 NAME

scripts::DBUpdateTo11_0::DBUpdateDynamicFieldValue - Update dynamic_field_value to include set and value indices and use BIGINT as id

=cut

use parent qw(scripts::DBUpdateTo11_0::Base);

sub Run { my ( $Self, %Param ) = @_;

# Initialize the DBObject
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');

# Check if id column is already BIGINT
my $SQL = "SHOW COLUMNS FROM dynamic_field_value LIKE 'id'";
$DBObject->Prepare(
    SQL => $SQL,
);

my $IDColumnType;
while ( my @Row = $DBObject->FetchrowArray() ) {
    $IDColumnType = $Row[1];
}

# Change id to BIGINT NOT NULL if it's not already BIGINT
if ($IDColumnType && $IDColumnType !~ /bigint/i) {
    my $Success = $DBObject->Do(
        SQL => 'ALTER TABLE dynamic_field_value CHANGE id id BIGINT NOT NULL',
    );

    if (!$Success) {
        $Self->{LogObject}->Log(
            Priority => 'error',
            Message  => "Error during execution of 'ALTER TABLE dynamic_field_value CHANGE id id BIGINT NOT NULL'!",
        );
        return 0;
    }
}

return 1;

}

1;

Please update your how-to to version 11.0 on your website

bschmalhofer commented 1 month ago

@smellord This issue should be fixed, or worked around, in the upcoming release OTOBO 11.0.2. See #3414 .

svenoe commented 1 month ago

11.0.2 is already out - I will close this issue. Please let us know, if it still persists.