From 1673ed8c719083924e80faab99d863939979ebc0 Mon Sep 17 00:00:00 2001
From: Thomas Citharel <tcit@tcit.fr>
Date: Thu, 22 Mar 2018 14:40:16 +0100
Subject: [PATCH] Fix MySQL NO_ZERO_DATE issue previous fix. Correct SQL and
 execute only on MySQL.

Closes #281

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
---
 .../Framadate/Migration/Fix_MySQL_No_Zero_Date.php     | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/app/classes/Framadate/Migration/Fix_MySQL_No_Zero_Date.php b/app/classes/Framadate/Migration/Fix_MySQL_No_Zero_Date.php
index eb4a7693..6eae5921 100644
--- a/app/classes/Framadate/Migration/Fix_MySQL_No_Zero_Date.php
+++ b/app/classes/Framadate/Migration/Fix_MySQL_No_Zero_Date.php
@@ -44,7 +44,7 @@ class Fix_MySQL_No_Zero_Date implements Migration {
      * It is called before the execute method.
      *
      * @param \PDO $pdo The connection to database
-     * @return bool true is the Migration should be executed.
+     * @return bool true if the Migration should be executed.
      */
     function preCondition(\PDO $pdo) {
         $stmt = $pdo->prepare("SELECT Column_Default from Information_Schema.Columns where Table_Name = ? AND Column_Name = ?;");
@@ -53,16 +53,18 @@ class Fix_MySQL_No_Zero_Date implements Migration {
         $stmt->execute();
         $default = $stmt->fetch(\PDO::FETCH_COLUMN);
 
-        return $default !== null;
+        $driver_name = $pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
+
+        return $default !== null && $driver_name === 'mysql';
     }
 
     /**
      * 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
+     * @return bool|void if the execution succeeded
      */
     function execute(\PDO $pdo) {
-        $pdo->exec('ALTER TABLE ' . Utils::table('poll') . ' CHANGE COLUMN end_date TIMESTAMP NULL DEFAULT NULL');
+        $pdo->exec('ALTER TABLE ' . Utils::table('poll') . ' MODIFY end_date TIMESTAMP NULL DEFAULT NULL;');
     }
 }
-- 
GitLab