fetchColumn(2)) !== false) { Database::exec("ALTER TABLE `exams_x_location` DROP INDEX `$name`"); } $ret = Database::exec("ALTER TABLE `exams_x_location` MODIFY `locationid` int(11) NULL"); if ($ret === false) { finalResponse(UPDATE_FAILED, 'Making locationid NULLable failed: ' . Database::lastError()); } // Ad our two keys; can't use PRIMARY as it doesn't allow columns that can be NULL Database::exec('ALTER TABLE `exams_x_location` ADD UNIQUE KEY (`examid`, `locationid`), ADD KEY (`locationid`)'); } // Constraints for locationid and examid $res[] = tableAddConstraint('exams_x_location', 'locationid', 'location', 'locationid', 'ON DELETE CASCADE ON UPDATE CASCADE', false, 'exl_locid_null'); $res[] = tableAddConstraint('exams_x_location', 'examid', 'exams', 'examid', 'ON DELETE CASCADE ON UPDATE CASCADE'); if (in_array(UPDATE_DONE, $res)) { finalResponse(UPDATE_DONE, 'Tables created successfully'); } finalResponse(UPDATE_NOOP, 'Everything already up to date');