diff --git a/admin/migration.php b/admin/migration.php index 166f790..3948909 100644 --- a/admin/migration.php +++ b/admin/migration.php @@ -24,6 +24,7 @@ use Framadate\Migration\AddColumn_ValueMax_In_poll_For_1_1; use Framadate\Migration\AddColumns_password_hash_And_results_publicly_visible_In_poll_For_0_9; use Framadate\Migration\Alter_Comment_table_adding_date; use Framadate\Migration\Alter_Comment_table_for_name_length; +use Framadate\Migration\Fix_MySQL_No_Zero_Date; use Framadate\Migration\From_0_0_to_0_8_Migration; use Framadate\Migration\From_0_8_to_0_9_Migration; use Framadate\Migration\Generate_uniqId_for_old_votes; @@ -49,11 +50,14 @@ $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() + new Increase_pollId_size(), + new AddColumn_ValueMax_In_poll_For_1_1(), + new Fix_MySQL_No_Zero_Date(), ]; // --------------------------------------- // Check if MIGRATION_TABLE already exists +/** @var \Framadate\FramaDB $connect */ $tables = $connect->allTables(); $pdo = $connect->getPDO(); $prefixedMigrationTable = Utils::table(MIGRATION_TABLE); diff --git a/app/classes/Framadate/Migration/Fix_MySQL_No_Zero_Date.php b/app/classes/Framadate/Migration/Fix_MySQL_No_Zero_Date.php new file mode 100644 index 0000000..eb4a769 --- /dev/null +++ b/app/classes/Framadate/Migration/Fix_MySQL_No_Zero_Date.php @@ -0,0 +1,68 @@ +prepare("SELECT Column_Default from Information_Schema.Columns where Table_Name = ? AND Column_Name = ?;"); + $stmt->bindValue(1, Utils::table('poll')); + $stmt->bindValue(2, 'end_date'); + $stmt->execute(); + $default = $stmt->fetch(\PDO::FETCH_COLUMN); + + return $default !== null; + } + + /** + * This method is called only one time in the migration page. + * + * @param \PDO $pdo The connection to database + * @return void true is the execution succeeded + */ + function execute(\PDO $pdo) { + $pdo->exec('ALTER TABLE ' . Utils::table('poll') . ' CHANGE COLUMN end_date TIMESTAMP 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 4dd1e12..092de91 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 @@ -71,7 +71,7 @@ CREATE TABLE IF NOT EXISTS `sondage` ( `titre` text, `id_sondage_admin` char(24) DEFAULT NULL, `date_creation` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `date_fin` timestamp NOT NULL, + `date_fin` timestamp NULL DEFAULT NULL, `format` varchar(2) DEFAULT NULL, `mailsonde` tinyint(1) DEFAULT \'0\', `statut` int(11) NOT NULL DEFAULT \'1\' COMMENT \'1 = actif ; 0 = inactif ; \', 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 c8f1096..bb8ab78 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 @@ -89,7 +89,7 @@ CREATE TABLE IF NOT EXISTS `' . Utils::table('poll') . '` ( `admin_name` VARCHAR(64) DEFAULT NULL, `admin_mail` VARCHAR(128) DEFAULT NULL, `creation_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - `end_date` TIMESTAMP NOT NULL, + `end_date` TIMESTAMP NULL DEFAULT NULL, `format` VARCHAR(1) DEFAULT NULL, `editable` TINYINT(1) DEFAULT \'0\', `receiveNewVotes` TINYINT(1) DEFAULT \'0\',