fix add columns for db2
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7320 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
2487d58bd7
commit
b76b8f87a5
@ -862,7 +862,11 @@ sub new
|
||||
|
||||
=head3 updateschema
|
||||
|
||||
Description: Alters table schema
|
||||
Description: Alters table info in the database based on Schema changes
|
||||
Handles adding attributes
|
||||
Handles removing attributes but does not really remove them
|
||||
from the database.
|
||||
Handles adding keys
|
||||
|
||||
Arguments: Hash containing Database and Table Handle and schema
|
||||
|
||||
@ -976,18 +980,27 @@ sub updateschema
|
||||
} else{
|
||||
$datatype=get_datatype_string($dcol, $xcatcfg, $types);
|
||||
}
|
||||
if ($datatype eq "TEXT") {
|
||||
if (isAKey(\@{$descr->{keys}}, $dcol)) { # keys
|
||||
$datatype = "VARCHAR(128) ";
|
||||
}
|
||||
if ($datatype eq "TEXT") { # keys cannot be TEXT
|
||||
if (isAKey(\@{$descr->{keys}}, $dcol)) { # keys
|
||||
$datatype = "VARCHAR(128) ";
|
||||
}
|
||||
}
|
||||
|
||||
if (grep /^$dcol$/, @{$descr->{required}})
|
||||
{
|
||||
$datatype .= " NOT NULL";
|
||||
}
|
||||
my $tmpcol=$dcol; # for sqlite
|
||||
if ($xcatcfg =~ /^DB2:/){
|
||||
$tmpcol="\"$dcol\"";
|
||||
|
||||
} else {
|
||||
if ($xcatcfg =~ /^mysql:/) {
|
||||
$tmpcol="\`$dcol\`";
|
||||
}
|
||||
}
|
||||
my $stmt =
|
||||
"ALTER TABLE " . $self->{tabname} . " ADD $dcol $datatype";
|
||||
"ALTER TABLE " . $self->{tabname} . " ADD $tmpcol $datatype";
|
||||
$self->{dbh}->do($stmt);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user