1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
9	header("location: index.php");
10	exit;
11}
12
13/**
14 * Added in 2018 for tiki 19 - need to change the defaults for datetimes from 0000-00-00 to null for mysql > 5.6
15 * @param $installer
16 */
17function upgrade_20111231_change_datetime_defaults_to_null_tiki($installer)
18{
19
20	// time_to_send was dropped in 20120123_remove_column_from_tiki_user_reports_tiki.sql
21	$query = $installer->query("SHOW COLUMNS FROM `tiki_user_reports` LIKE 'time_to_send';");
22	if ($query->result) {
23		$installer->query("ALTER TABLE `tiki_user_reports` CHANGE `last_report` `last_report` DATETIME  NULL, CHANGE `time_to_send` `time_to_send` DATETIME  NULL;");
24	} else {
25		$installer->query("ALTER TABLE `tiki_user_reports` CHANGE `last_report` `last_report` DATETIME  NULL;");
26	}
27
28	$installer->query("ALTER TABLE `tiki_user_reports_cache` CHANGE `time` `time` DATETIME  NULL;");
29	$installer->query("ALTER TABLE `tiki_payment_requests` CHANGE `due_date` `due_date` DATETIME  NULL;");
30}
31