From 4e01d07da0b989dc16f305998b77c71cfc141b01 Mon Sep 17 00:00:00 2001 From: Antonin <zepcome@gmail.com> Date: Thu, 9 Apr 2015 12:34:48 +0200 Subject: [PATCH] Added column password in poll table. --- admin/migration.php | 4 +- .../AddColumn_hidden_In_poll_For_0_9.php | 2 +- .../AddColumn_receiveNewComments_For_0_9.php | 2 +- .../AddColumn_uniqId_In_vote_For_0_9.php | 2 +- ...sults_publicly_visible_In_poll_For_0_9.php | 78 +++++++++++++++++++ .../Migration/From_0_0_to_0_8_Migration.php | 2 +- .../Migration/From_0_8_to_0_9_Migration.php | 2 +- 7 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 app/classes/Framadate/Migration/AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9.php diff --git a/admin/migration.php b/admin/migration.php index 5ed3c705..ad58d667 100644 --- a/admin/migration.php +++ b/admin/migration.php @@ -25,6 +25,7 @@ use Framadate\Migration\AddColumn_hidden_In_poll_For_0_9; 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\Migration; use Framadate\Migration\RPadVotes_from_0_8; use Framadate\Utils; @@ -43,7 +44,8 @@ $migrations = [ new Generate_uniqId_for_old_votes(), new RPadVotes_from_0_8(), new Alter_Comment_table_for_name_length(), - new Alter_Comment_table_adding_date() + new Alter_Comment_table_adding_date(), + new AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9(), ]; // --------------------------------------- diff --git a/app/classes/Framadate/Migration/AddColumn_hidden_In_poll_For_0_9.php b/app/classes/Framadate/Migration/AddColumn_hidden_In_poll_For_0_9.php index dd335f98..f03356f7 100644 --- a/app/classes/Framadate/Migration/AddColumn_hidden_In_poll_For_0_9.php +++ b/app/classes/Framadate/Migration/AddColumn_hidden_In_poll_For_0_9.php @@ -57,7 +57,7 @@ class AddColumn_hidden_In_poll_For_0_9 implements Migration { } /** - * This methode is called only one time in the migration page. + * This method is called only one time in the migration page. * * @param \PDO $pdo The connection to database * @return bool true is the execution succeeded diff --git a/app/classes/Framadate/Migration/AddColumn_receiveNewComments_For_0_9.php b/app/classes/Framadate/Migration/AddColumn_receiveNewComments_For_0_9.php index 865502ae..850fc63d 100644 --- a/app/classes/Framadate/Migration/AddColumn_receiveNewComments_For_0_9.php +++ b/app/classes/Framadate/Migration/AddColumn_receiveNewComments_For_0_9.php @@ -57,7 +57,7 @@ class AddColumn_receiveNewComments_For_0_9 implements Migration { } /** - * This methode is called only one time in the migration page. + * This method is called only one time in the migration page. * * @param \PDO $pdo The connection to database * @return bool true is the execution succeeded diff --git a/app/classes/Framadate/Migration/AddColumn_uniqId_In_vote_For_0_9.php b/app/classes/Framadate/Migration/AddColumn_uniqId_In_vote_For_0_9.php index 440d2de2..0b919857 100644 --- a/app/classes/Framadate/Migration/AddColumn_uniqId_In_vote_For_0_9.php +++ b/app/classes/Framadate/Migration/AddColumn_uniqId_In_vote_For_0_9.php @@ -57,7 +57,7 @@ class AddColumn_uniqId_In_vote_For_0_9 implements Migration { } /** - * This methode is called only one time in the migration page. + * This method is called only one time in the migration page. * * @param \PDO $pdo The connection to database * @return bool true is the execution succeeded diff --git a/app/classes/Framadate/Migration/AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9.php b/app/classes/Framadate/Migration/AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9.php new file mode 100644 index 00000000..9e6e5cac --- /dev/null +++ b/app/classes/Framadate/Migration/AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9.php @@ -0,0 +1,78 @@ +<?php +/** + * This software is governed by the CeCILL-B license. If a copy of this license + * is not distributed with this file, you can obtain one at + * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt + * + * Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ + * Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft) + * + * ============================= + * + * Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence + * ne se trouve pas avec ce fichier vous pouvez l'obtenir sur + * http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt + * + * Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ + * Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft) + */ +namespace Framadate\Migration; + +use Framadate\Utils; + +/** + * This migration adds the fields password_hash and results_publicly_visible on the poll table. + * + * @package Framadate\Migration + * @version 0.9 + */ +class AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9 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 'Add columns "password_hash" and "results_publicly_visible" in table "vote" for version 0.9'; + } + + /** + * 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 is the Migration should be executed. + */ + function preCondition(\PDO $pdo) { + $stmt = $pdo->query('SHOW TABLES'); + $tables = $stmt->fetchAll(\PDO::FETCH_COLUMN); + + // Check if tables of v0.9 are presents + $diff = array_diff([Utils::table('poll'), Utils::table('slot'), Utils::table('vote'), Utils::table('comment')], $tables); + return count($diff) === 0; + } + + /** + * This method is called only one time in the migration page. + * + * @param \PDO $pdo The connection to database + * @return bool true is the execution succeeded + */ + function execute(\PDO $pdo) { + $this->alterPollTable($pdo); + + return true; + } + + private function alterPollTable(\PDO $pdo) { + $pdo->exec(' + ALTER TABLE `' . Utils::table('poll') . '` + ADD `password_hash` VARCHAR(255) NULL DEFAULT NULL , + ADD `results_publicly_visible` TINYINT(1) NULL DEFAULT NULL'); + } + +} diff --git a/app/classes/Framadate/Migration/From_0_0_to_0_8_Migration.php b/app/classes/Framadate/Migration/From_0_0_to_0_8_Migration.php index ac985f50..01ea8382 100644 --- a/app/classes/Framadate/Migration/From_0_0_to_0_8_Migration.php +++ b/app/classes/Framadate/Migration/From_0_0_to_0_8_Migration.php @@ -57,7 +57,7 @@ class From_0_0_to_0_8_Migration implements Migration { } /** - * This methode is called only one time in the migration page. + * This method is called only one time in the migration page. * * @param \PDO $pdo The connection to database * @return bool true is the execution succeeded diff --git a/app/classes/Framadate/Migration/From_0_8_to_0_9_Migration.php b/app/classes/Framadate/Migration/From_0_8_to_0_9_Migration.php index 45984498..fa7f40cc 100644 --- a/app/classes/Framadate/Migration/From_0_8_to_0_9_Migration.php +++ b/app/classes/Framadate/Migration/From_0_8_to_0_9_Migration.php @@ -57,7 +57,7 @@ class From_0_8_to_0_9_Migration implements Migration { } /** - * This methode is called only one time in the migration page. + * This method is called only one time in the migration page. * * @param \PDO $pdo The connection to database * @return bool true is the execution succeeded -- GitLab