function alterTableCompetitions() { #---------------------------------------------------------------------- #--- Alter the field set. reportAction("Competitions", "Alter field set"); dbCommand("\n ALTER TABLE Competitions\n ADD COLUMN `showAtAll` BOOLEAN NOT NULL DEFAULT 0,\n ADD COLUMN `showResults` BOOLEAN NOT NULL DEFAULT 0,\n ADD COLUMN `password` VARCHAR(45) NOT NULL;\n "); #--- Make showAtAll true, and showResults true for all competitions with results. reportAction("Competitions", "Set {showAtAll,showResults}"); dbCommand("UPDATE Competitions SET showAtAll=1"); dbCommand("\n UPDATE Competitions competition, Results result\n SET competition.showResults = 1\n WHERE competition.id = result.competitionId;\n "); #--- Generate passwords for all competitions. reportAction("Competitions", "Generate passwords"); $competitions = dbQuery("SELECT id FROM Competitions"); foreach ($competitions as $competition) { extract($competition); $password = generateNewPassword($id); dbCommand("\n UPDATE Competitions\n SET password='******'\n WHERE id='{$id}'\n "); } }
function alterTableCompetitions() { #---------------------------------------------------------------------- #--- Alter the field set. reportAction("Competitions", "Change columns"); dbCommand("ALTER TABLE Competitions\n ALTER COLUMN `showAtAll` SET DEFAULT '0'"); dbCommand("ALTER TABLE Competitions\n ADD COLUMN `adminPassword` VARCHAR(45) NOT NULL DEFAULT ''"); dbCommand("ALTER TABLE Competitions\n ADD COLUMN `isConfirmed` TINYINT(1) NOT NULL DEFAULT '0'"); dbCommand("ALTER TABLE Competitions\n CHANGE password organiserPassword VARCHAR(45)"); dbCommand("ALTER TABLE Competitions\n DROP COLUMN `showResults`"); #--- Generate admin passwords for all competitions. reportAction("Competitions", "Generate admin passwords"); $competitions = dbQuery("SELECT id FROM Competitions"); foreach ($competitions as $competition) { extract($competition); $password = generateNewPassword($id); dbCommand("\n UPDATE Competitions\n SET adminPassword='******'\n WHERE id='{$id}'\n "); } #--- Set all competitions to confirmed status. reportAction("Competitions", "Change to confirmed"); dbCommand("\n UPDATE Competitions\n SET isConfirmed='1'\n "); }
function alterTableCompetitions() { #---------------------------------------------------------------------- #--- Alter the field set. reportAction("Competitions", "Alter field set"); dbCommand("\n ALTER TABLE Competitions\n DROP COLUMN `comments`,\n DROP COLUMN `articles`,\n DROP COLUMN `reports`,\n DROP COLUMN `multimedia`,\n CHANGE COLUMN `eventIds` `eventSpecs` TEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,\n ADD COLUMN `preregPreface` TEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,\n ADD COLUMN `showAtAll` BOOLEAN NOT NULL DEFAULT 0,\n ADD COLUMN `showResults` BOOLEAN NOT NULL DEFAULT 0,\n ADD COLUMN `showPreregForm` BOOLEAN NOT NULL DEFAULT 0,\n ADD COLUMN `showPreregList` BOOLEAN NOT NULL DEFAULT 0,\n ADD COLUMN `viewPassword` VARCHAR(45) NOT NULL,\n ADD COLUMN `editPassword` VARCHAR(45) NOT NULL;\n "); #--- Make showAtAll true, and showResults true for all competitions with results. reportAction("Competitions", "Set {showAtAll,showResults}"); dbCommand("UPDATE Competitions SET showAtAll=1"); dbCommand("\n UPDATE Competitions competition, Results result\n SET competition.showResults = 1\n WHERE competition.id = result.competitionId;\n "); #--- Generate passwords for all competitions. reportAction("Competitions", "Generate passwords"); $competitions = dbQuery("SELECT id FROM Competitions"); foreach ($competitions as $competition) { extract($competition); $password = generateNewPassword($id); dbCommand("\n UPDATE Competitions\n SET viewPassword='******', editPassword='******'\n WHERE id='{$id}'\n "); } #--- Repace endMonth/endDay zeroes with positive numbers. reportAction("Competitions", "Replace endMonth/endDay zeroes"); dbCommand("UPDATE Competitions SET endMonth=month WHERE endMonth=0"); dbCommand("UPDATE Competitions SET endDay=day WHERE endDay=0"); }