Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
latoilescoute-dev
scoodle
Commits
d3eedbcb
Commit
d3eedbcb
authored
Mar 21, 2018
by
Thomas Citharel
Browse files
Fix MySQL NO_ZERO_DATE
Closes #224 Signed-off-by:
Thomas Citharel
<
tcit@tcit.fr
>
parent
0e9075a9
Changes
4
Hide whitespace changes
Inline
Side-by-side
admin/migration.php
View file @
d3eedbcb
...
...
@@ -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
);
...
...
app/classes/Framadate/Migration/Fix_MySQL_No_Zero_Date.php
0 → 100644
View file @
d3eedbcb
<?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/OpenSondage: 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 sets Poll.end_date to NULL by default
*
* @package Framadate\Migration
* @version 1.1
*/
class
Fix_MySQL_No_Zero_Date
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
'Sets Poll end_date to NULL by default (work around MySQL NO_ZERO_DATE)'
;
}
/**
* 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
->
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'
);
}
}
app/classes/Framadate/Migration/From_0_0_to_0_8_Migration.php
View file @
d3eedbcb
...
...
@@ -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 N
O
T NULL,
`date_fin` timestamp N
ULL DEFAUL
T NULL,
`format` varchar(2) DEFAULT NULL,
`mailsonde` tinyint(1) DEFAULT \'0\',
`statut` int(11) NOT NULL DEFAULT \'1\' COMMENT \'1 = actif ; 0 = inactif ; \',
...
...
app/classes/Framadate/Migration/From_0_8_to_0_9_Migration.php
View file @
d3eedbcb
...
...
@@ -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 N
O
T NULL,
`end_date` TIMESTAMP N
ULL DEFAUL
T NULL,
`format` VARCHAR(1) DEFAULT NULL,
`editable` TINYINT(1) DEFAULT \'0\',
`receiveNewVotes` TINYINT(1) DEFAULT \'0\',
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment