diff --git a/admin/migration.php b/admin/migration.php index ad58d667ea1272746c24bc84e0dfb2a5cf731dd1..cf8f8f9b98f5297b37fb80f86a048d7a053c0160 100644 --- a/admin/migration.php +++ b/admin/migration.php @@ -26,6 +26,7 @@ use Framadate\Migration\Alter_Comment_table_for_name_length; use Framadate\Migration\Alter_Comment_table_adding_date; use Framadate\Migration\Generate_uniqId_for_old_votes; use Framadate\Migration\AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9; +use Framadate\Migration\Increase_pollId_size; use Framadate\Migration\Migration; use Framadate\Migration\RPadVotes_from_0_8; use Framadate\Utils; @@ -46,6 +47,7 @@ $migrations = [ new Alter_Comment_table_for_name_length(), new Alter_Comment_table_adding_date(), new AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9(), + new Increase_pollId_size() ]; // --------------------------------------- diff --git a/app/classes/Framadate/Migration/Increase_pollId_size.php b/app/classes/Framadate/Migration/Increase_pollId_size.php new file mode 100644 index 0000000000000000000000000000000000000000..80fb500ec4c99f724c52f62eb1d3e440845f91a3 --- /dev/null +++ b/app/classes/Framadate/Migration/Increase_pollId_size.php @@ -0,0 +1,46 @@ +<?php +namespace Framadate\Migration; + +use Framadate\Utils; + +class Increase_pollId_size implements Migration { + + function __construct() { + } + + /** + * This method should describe in english what is the purpose of the migration class. + * + * @return string The description of the migration class + */ + function description() { + return 'Increase the size of id column in poll table'; + } + + /** + * This method could check if the execute method should be called. + * It is called before the execute method. + * + * @param \PDO $pdo The connection to database + * @return bool true if the Migration should be executed + */ + function preCondition(\PDO $pdo) { + return true; + } + + /** + * This methode is called only one time in the migration page. + * + * @param \PDO $pdo The connection to database + * @return bool true if the execution succeeded + */ + function execute(\PDO $pdo) { + $this->alterPollTable($pdo); + } + + private function alterPollTable(\PDO $pdo) { + $pdo->exec(' + ALTER TABLE `' . Utils::table('poll') . '` + CHANGE `id` `id` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;'); + } +}