Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Kernel/System/MigrateFromOTRS/CloneDB/Driver/mysql.pm
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ sub TranslateColumnInfos {
}

# Alter table add column
# Note: add also custom columns which not belongs to standard
sub AlterTableAddColumn {
my ( $Self, %Param ) = @_;

Expand All @@ -288,15 +289,20 @@ sub AlterTableAddColumn {
my $SQL = qq{ALTER TABLE $Param{Table} ADD $Param{Column} $ColumnInfos{DATA_TYPE}};

if ( $ColumnInfos{LENGTH} ) {
$SQL .= " \($ColumnInfos{LENGTH}\)";
$SQL .= " ($ColumnInfos{LENGTH})";
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that $ColumnInfos{COLUMN_DEFAULT} should be quoted, just in case it contains a single quote character.

if ( $ColumnInfos{IS_NULLABLE} =~ m/no/ ) {
$SQL .= ' NOT NULL';
if ( $ColumnInfos{COLUMN_DEFAULT} ) {
$SQL .= " DEFAULT '$ColumnInfos{COLUMN_DEFAULT}'";
}

# IS_NULLABLE is either YES or NO
if ( $ColumnInfos{IS_NULLABLE} eq "NO" ) {
$SQL .= " NOT NULL";
}

my $Success = $Param{DBObject}->Do(
SQL => $SQL,
SQL => $SQL,
);

if ( !$Success ) {
Expand Down
13 changes: 9 additions & 4 deletions Kernel/System/MigrateFromOTRS/CloneDB/Driver/oracle.pm
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ sub TranslateColumnInfos {
}

# Alter table add column
# Note: add also custom columns which not belongs to standard
sub AlterTableAddColumn {
my ( $Self, %Param ) = @_;

Expand All @@ -373,16 +374,20 @@ sub AlterTableAddColumn {
my $SQL = qq{ALTER TABLE $Param{Table} ADD $Param{Column} $ColumnInfos{DATA_TYPE}};

if ( $ColumnInfos{LENGTH} ) {
$SQL .= " \($ColumnInfos{LENGTH}\)";
$SQL .= " ($ColumnInfos{LENGTH})";
}

if ( $ColumnInfos{COLUMN_DEFAULT} ) {
$SQL .= " DEFAULT '$ColumnInfos{COLUMN_DEFAULT}'";
}

# IS_NULLABLE is either YES or NO
if ( $ColumnInfos{IS_NULLABLE} =~ m/no/i ) {
$SQL .= ' NOT NULL';
if ( $ColumnInfos{IS_NULLABLE} eq "NO" ) {
$SQL .= " NOT NULL";
}

my $Success = $Param{DBObject}->Do(
SQL => $SQL,
SQL => $SQL,
);

if ( !$Success ) {
Expand Down
14 changes: 10 additions & 4 deletions Kernel/System/MigrateFromOTRS/CloneDB/Driver/postgresql.pm
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ sub TranslateColumnInfos {
}

# Alter table add column
# Note: add also custom columns which not belongs to standard
sub AlterTableAddColumn {
my ( $Self, %Param ) = @_;

Expand All @@ -343,15 +344,20 @@ sub AlterTableAddColumn {
my $SQL = qq{ALTER TABLE $Param{Table} ADD $Param{Column} $ColumnInfos{DATA_TYPE}};

if ( $ColumnInfos{LENGTH} ) {
$SQL .= " \($ColumnInfos{LENGTH}\)";
$SQL .= " ($ColumnInfos{LENGTH})";
}

if ( $ColumnInfos{IS_NULLABLE} =~ m/no/ ) {
$SQL .= ' NOT NULL';
if ( $ColumnInfos{COLUMN_DEFAULT} ) {
$SQL .= " DEFAULT '$ColumnInfos{COLUMN_DEFAULT}'";
}

# IS_NULLABLE is either YES or NO
if ( $ColumnInfos{IS_NULLABLE} eq "NO" ) {
$SQL .= " NOT NULL";
}

my $Success = $Param{DBObject}->Do(
SQL => $SQL,
SQL => $SQL,
);

if ( !$Success ) {
Expand Down