X-Git-Url: http://git.pippins.net/embedvideo/.git/?a=blobdiff_plain;f=bin%2Fupgrade_1_1_0_to_1_1_1;fp=bin%2Fupgrade_1_1_0_to_1_1_1;h=6745e589250ddad82e43597afe7ef61411128574;hb=61df0220f9c24a23b834d1fdf64c2a3630e52560;hp=5c934cbdfa31b88ad68be282123757844c65bd55;hpb=b5c74cd3f678ed412df81cda7f8f77344d374d7a;p=eq%2F.git diff --git a/bin/upgrade_1_1_0_to_1_1_1 b/bin/upgrade_1_1_0_to_1_1_1 index 5c934cb..6745e58 100755 --- a/bin/upgrade_1_1_0_to_1_1_1 +++ b/bin/upgrade_1_1_0_to_1_1_1 @@ -40,14 +40,6 @@ $sth->execute or die "-E- DB error: $DBI::errstr\n"; $sth = $dbh->prepare("ALTER TABLE `tc_companionship` ADD `type` ENUM( 'H', 'P' ) NOT NULL DEFAULT 'H' AFTER `district`"); $sth->execute or die "-E- DB error: $DBI::errstr\n"; -# rename supervisor field in tc_district to leader -$sth = $dbh->prepare("ALTER TABLE `tc_district` CHANGE `supervisor` `leader` INT( 16 ) UNSIGNED NULL DEFAULT NULL"); -$sth->execute or die "-E- DB error: $DBI::errstr\n"; - -# rename supervisor field in tc_district_sandbox to leader -$sth = $dbh->prepare("ALTER TABLE `tc_district_sandbox` CHANGE `supervisor` `leader` INT( 16 ) UNSIGNED NULL DEFAULT NULL"); -$sth->execute or die "-E- DB error: $DBI::errstr\n"; - # rename presidency field in tc_appointment to leader $sth = $dbh->prepare("ALTER TABLE `tc_appointment` CHANGE `presidency` `leader` INT( 16 ) UNSIGNED NOT NULL DEFAULT '0'"); $sth->execute or die "-E- DB error: $DBI::errstr\n"; @@ -74,6 +66,23 @@ $sth->execute or die "-E- DB error: $DBI::errstr\n"; $sth = $dbh->prepare("ALTER TABLE `tc_leader` DROP `president`, DROP `counselor`, DROP `secretary`"); $sth->execute or die "-E- DB error: $DBI::errstr\n"; +# rename supervisor field in tc_district to leader +$sth = $dbh->prepare("ALTER TABLE `tc_district` CHANGE `supervisor` `leader` INT( 16 ) UNSIGNED NULL DEFAULT NULL"); +$sth->execute or die "-E- DB error: $DBI::errstr\n"; +$sth = $dbh->prepare("UPDATE tc_district AS td JOIN tc_leader AS tl SET td.leader=tl.leader WHERE td.leader=tl.individual AND td.district=tl.district AND tl.valid=1 AND td.valid=1"); +$sth->execute or die "-E- DB error: $DBI::errstr\n"; + +# rename supervisor field in tc_district_sandbox to leader +$sth = $dbh->prepare("ALTER TABLE `tc_district_sandbox` CHANGE `supervisor` `leader` INT( 16 ) UNSIGNED NULL DEFAULT NULL"); +$sth->execute or die "-E- DB error: $DBI::errstr\n"; +$sth = $dbh->prepare("UPDATE tc_district_sandbox AS tdc JOIN tc_leader AS tl SET tdc.leader=tl.leader WHERE tdc.leader=tl.individual AND tdc.district=tl.district AND tl.valid=1"); +$sth->execute or die "-E- DB error: $DBI::errstr\n"; + +# remove district field from tc_leader +$sth = $dbh->prepare("ALTER TABLE `tc_leader` DROP `district`"); +$sth->execute or die "-E- DB error: $DBI::errstr\n"; + + print "-> Done!\n";