Added column password in poll table.

This commit is contained in:
Antonin 2015-04-09 12:34:48 +02:00
parent 1ba245258a
commit f888a643e0
7 changed files with 86 additions and 6 deletions

View File

@ -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_for_name_length;
use Framadate\Migration\Alter_Comment_table_adding_date; use Framadate\Migration\Alter_Comment_table_adding_date;
use Framadate\Migration\Generate_uniqId_for_old_votes; 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\Migration;
use Framadate\Migration\RPadVotes_from_0_8; use Framadate\Migration\RPadVotes_from_0_8;
use Framadate\Utils; use Framadate\Utils;
@ -43,7 +44,8 @@ $migrations = [
new Generate_uniqId_for_old_votes(), new Generate_uniqId_for_old_votes(),
new RPadVotes_from_0_8(), new RPadVotes_from_0_8(),
new Alter_Comment_table_for_name_length(), 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(),
]; ];
// --------------------------------------- // ---------------------------------------

View File

@ -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 * @param \PDO $pdo The connection to database
* @return bool true is the execution succeeded * @return bool true is the execution succeeded

View File

@ -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 * @param \PDO $pdo The connection to database
* @return bool true is the execution succeeded * @return bool true is the execution succeeded

View File

@ -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 * @param \PDO $pdo The connection to database
* @return bool true is the execution succeeded * @return bool true is the execution succeeded

View File

@ -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');
}
}

View File

@ -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 * @param \PDO $pdo The connection to database
* @return bool true is the execution succeeded * @return bool true is the execution succeeded

View File

@ -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 * @param \PDO $pdo The connection to database
* @return bool true is the execution succeeded * @return bool true is the execution succeeded