From 421f86d8a303559151329eb5737b0f652347b068 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ <olivier@olivierperez.fr> Date: Sat, 5 Dec 2015 14:24:38 +0100 Subject: [PATCH] UrlNaming - Increase size of poll's id column --- admin/migration.php | 2 + .../Migration/Increase_pollId_size.php | 46 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 app/classes/Framadate/Migration/Increase_pollId_size.php diff --git a/admin/migration.php b/admin/migration.php index ad58d667..cf8f8f9b 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 00000000..80fb500e --- /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;'); + } +} -- GitLab