Bug 36755: Atomicupdate file
Test plan, k-t-d: 1) Apply patches. 2) Run the following SQL and save the output of each: SHOW CREATE TABLE pseudonymized_borrower_attributes; SHOW CREATE TABLE borrower_attribute_types_branches; SHOW CREATE TABLE borrower_attributes; SHOW CREATE TABLE borrower_attribute_types; 3) Run updatedatabase 4) Run the SQL queries again, compare the output of each with the previous output before updatedatabase. 5) Make sure the only diff between the two is VARCHAR(10) -> VARCHAR(64) Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
ac19b97974
commit
ffd47c373a
|
|
@ -0,0 +1,72 @@
|
|||
use Modern::Perl;
|
||||
|
||||
return {
|
||||
bug_number => "36755",
|
||||
description => "Increase length of 'code' column in borrower_attribute_types",
|
||||
up => sub {
|
||||
my ($args) = @_;
|
||||
my ( $dbh, $out ) = @$args{qw(dbh out)};
|
||||
|
||||
# Drop related tables constraints
|
||||
if ( foreign_key_exists( 'pseudonymized_borrower_attributes', 'anonymized_borrower_attributes_ibfk_2' ) ) {
|
||||
$dbh->do(
|
||||
q{ALTER TABLE pseudonymized_borrower_attributes DROP FOREIGN KEY anonymized_borrower_attributes_ibfk_2}
|
||||
);
|
||||
}
|
||||
if ( foreign_key_exists( 'borrower_attribute_types_branches', 'borrower_attribute_types_branches_ibfk_1' ) ) {
|
||||
$dbh->do(
|
||||
q{ALTER TABLE borrower_attribute_types_branches DROP FOREIGN KEY borrower_attribute_types_branches_ibfk_1}
|
||||
);
|
||||
}
|
||||
if ( foreign_key_exists( 'borrower_attributes', 'borrower_attributes_ibfk_2' ) ) {
|
||||
$dbh->do(q{ALTER TABLE borrower_attributes DROP FOREIGN KEY borrower_attributes_ibfk_2});
|
||||
}
|
||||
|
||||
# Update the column we want
|
||||
unless ( foreign_key_exists( 'pseudonymized_borrower_attributes', 'anonymized_borrower_attributes_ibfk_2' )
|
||||
|| foreign_key_exists( 'borrower_attribute_types_branches', 'borrower_attribute_types_branches_ibfk_1' )
|
||||
|| foreign_key_exists( 'borrower_attributes', 'borrower_attributes_ibfk_2' ) )
|
||||
{
|
||||
$dbh->do(
|
||||
q{ALTER TABLE borrower_attribute_types MODIFY COLUMN code VARCHAR(64) NOT NULL COMMENT 'unique key used to identify each custom field'}
|
||||
);
|
||||
}
|
||||
|
||||
# Update the related tables
|
||||
unless ( foreign_key_exists( 'pseudonymized_borrower_attributes', 'anonymized_borrower_attributes_ibfk_2' ) ) {
|
||||
$dbh->do(
|
||||
q{ALTER TABLE pseudonymized_borrower_attributes MODIFY COLUMN code VARCHAR(64) NOT NULL COMMENT 'foreign key from the borrower_attribute_types table, defines which custom field this value was entered for'}
|
||||
);
|
||||
}
|
||||
unless ( foreign_key_exists( 'borrower_attribute_types_branches', 'borrower_attribute_types_branches_ibfk_1' ) )
|
||||
{
|
||||
$dbh->do(q{ALTER TABLE borrower_attribute_types_branches MODIFY COLUMN bat_code VARCHAR(64) DEFAULT NULL});
|
||||
}
|
||||
unless ( foreign_key_exists( 'borrower_attributes', 'borrower_attributes_ibfk_2' ) ) {
|
||||
$dbh->do(
|
||||
q{ALTER TABLE borrower_attributes MODIFY COLUMN code VARCHAR(64) NOT NULL COMMENT 'foreign key from the borrower_attribute_types table, defines which custom field this value was entered for'}
|
||||
);
|
||||
}
|
||||
|
||||
# Restore related tables constraints
|
||||
unless ( foreign_key_exists( 'pseudonymized_borrower_attributes', 'anonymized_borrower_attributes_ibfk_2' ) ) {
|
||||
$dbh->do(
|
||||
q{ALTER TABLE pseudonymized_borrower_attributes ADD CONSTRAINT anonymized_borrower_attributes_ibfk_2 FOREIGN KEY (code) REFERENCES borrower_attribute_types(code) ON DELETE CASCADE ON UPDATE CASCADE}
|
||||
);
|
||||
}
|
||||
unless ( foreign_key_exists( 'borrower_attribute_types_branches', 'borrower_attribute_types_branches_ibfk_1' ) )
|
||||
{
|
||||
$dbh->do(
|
||||
q{ALTER TABLE borrower_attribute_types_branches ADD CONSTRAINT borrower_attribute_types_branches_ibfk_1 FOREIGN KEY (bat_code) REFERENCES borrower_attribute_types(code) ON DELETE CASCADE}
|
||||
);
|
||||
}
|
||||
unless ( foreign_key_exists( 'borrower_attributes', 'borrower_attributes_ibfk_2' ) ) {
|
||||
$dbh->do(
|
||||
q{ALTER TABLE borrower_attributes ADD CONSTRAINT borrower_attributes_ibfk_2 FOREIGN KEY (code) REFERENCES borrower_attribute_types(code) ON DELETE CASCADE ON UPDATE CASCADE}
|
||||
);
|
||||
}
|
||||
|
||||
# HTML customizations
|
||||
say $out "Increased borrower_attribute_types.code column length from 10 to 64";
|
||||
},
|
||||
};
|
||||
Loading…
Reference in New Issue