From 10660a9ee48b07e932ed8c5a1a8e29dea1023388 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Thu, 7 Jul 2016 22:34:21 +0300
Subject: Replace in sql files fields with default date/datetime into default
 NULL.

---
 sql-files/main.sql | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

(limited to 'sql-files/main.sql')

diff --git a/sql-files/main.sql b/sql-files/main.sql
index e2717cdc5..8466c3a14 100644
--- a/sql-files/main.sql
+++ b/sql-files/main.sql
@@ -236,7 +236,7 @@ CREATE TABLE IF NOT EXISTS `char_reg_str_db` (
 --
 
 CREATE TABLE IF NOT EXISTS `charlog` (
-  `time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `time` DATETIME NULL,
   `char_msg` VARCHAR(255) NOT NULL DEFAULT 'char select',
   `account_id` INT(11) NOT NULL DEFAULT '0',
   `char_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
@@ -511,7 +511,7 @@ CREATE TABLE IF NOT EXISTS `homunculus` (
 --
 
 CREATE TABLE IF NOT EXISTS `interlog` (
-  `time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `time` DATETIME NULL,
   `log` VARCHAR(255) NOT NULL DEFAULT ''
 ) ENGINE=MyISAM; 
 
@@ -546,8 +546,8 @@ CREATE TABLE IF NOT EXISTS `inventory` (
 
 CREATE TABLE IF NOT EXISTS `ipbanlist` (
   `list` VARCHAR(255) NOT NULL DEFAULT '',
-  `btime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-  `rtime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `btime` DATETIME NULL,
+  `rtime` DATETIME NULL,
   `reason` VARCHAR(255) NOT NULL DEFAULT '',
   KEY (`list`)
 ) ENGINE=MyISAM;
@@ -567,9 +567,9 @@ CREATE TABLE IF NOT EXISTS `login` (
   `unban_time` INT(11) UNSIGNED NOT NULL DEFAULT '0',
   `expiration_time` INT(11) UNSIGNED NOT NULL DEFAULT '0',
   `logincount` MEDIUMINT(9) UNSIGNED NOT NULL DEFAULT '0',
-  `lastlogin` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `lastlogin` DATETIME NULL, 
   `last_ip` VARCHAR(100) NOT NULL DEFAULT '',
-  `birthdate` DATE NOT NULL DEFAULT '0000-00-00',
+  `birthdate` DATE NULL,
   `character_slots` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
   `pincode` VARCHAR(4) NOT NULL DEFAULT '',
   `pincode_change` INT(11) UNSIGNED NOT NULL DEFAULT '0',
-- 
cgit v1.2.3-70-g09d2


From 6a84cbb2d527a0fb263a9104690bcfcb24f182e1 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Fri, 8 Jul 2016 02:59:20 +0300
Subject: Add sql upgrade scripts for convert date/datetime default values.

---
 sql-files/main.sql                          |  2 ++
 sql-files/upgrades/2016-07-08--02-42.sql    | 35 +++++++++++++++++++++++++++++
 sql-files/upgrades/2016-07-08--02-51.sql    | 30 +++++++++++++++++++++++++
 sql-files/upgrades/eAthena-logs-upgrade.sql |  9 ++++++++
 sql-files/upgrades/eAthena-main-upgrade.sql | 14 ++++++++++++
 sql-files/upgrades/index.txt                |  2 ++
 sql-files/upgrades/rAthena-logs-upgrade.sql |  8 +++++++
 sql-files/upgrades/rAthena-main-upgrade.sql | 13 +++++++++++
 8 files changed, 113 insertions(+)
 create mode 100644 sql-files/upgrades/2016-07-08--02-42.sql
 create mode 100644 sql-files/upgrades/2016-07-08--02-51.sql

(limited to 'sql-files/main.sql')

diff --git a/sql-files/main.sql b/sql-files/main.sql
index 8466c3a14..fe25fb100 100644
--- a/sql-files/main.sql
+++ b/sql-files/main.sql
@@ -825,6 +825,8 @@ INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1440688342); -- 2015-08-2
 INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1450241859); -- 2015-12-16--12-57.sql
 INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1450367880); -- 2015-12-17--15-58.sql
 INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1457638175); -- 2016-03-10--22-18.sql
+INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1467934919); -- 2016-07-08--02-42.sql
+INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1467935469); -- 2016-07-08--02-51.sql
 
 --
 -- Table structure for table `storage`
diff --git a/sql-files/upgrades/2016-07-08--02-42.sql b/sql-files/upgrades/2016-07-08--02-42.sql
new file mode 100644
index 000000000..94ca7e6db
--- /dev/null
+++ b/sql-files/upgrades/2016-07-08--02-42.sql
@@ -0,0 +1,35 @@
+#1467934919
+
+-- This file is part of Hercules.
+-- http://herc.ws - http://github.com/HerculesWS/Hercules
+--
+-- Copyright (C) 2015-2016  Hercules Dev Team
+--
+-- Hercules is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+ALTER TABLE `charlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `interlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `ipbanlist` MODIFY `btime` DATETIME NULL;
+ALTER TABLE `ipbanlist` MODIFY `rtime` DATETIME NULL;
+ALTER TABLE `login` MODIFY `lastlogin` DATETIME NULL;
+ALTER TABLE `login` MODIFY `birthdate` DATE NULL;
+
+UPDATE `charlog` SET `time` = NULL WHERE `time` = '0000-00-00 00:00:00';
+UPDATE `interlog` SET `time` = NULL WHERE `time` = '0000-00-00 00:00:00';
+UPDATE `ipbanlist` SET `btime` = NULL WHERE `btime` = '0000-00-00 00:00:00';
+UPDATE `ipbanlist` SET `rtime` = NULL WHERE `rtime` = '0000-00-00 00:00:00';
+UPDATE `login` SET `lastlogin` = NULL WHERE `lastlogin` = '0000-00-00 00:00:00';
+UPDATE `login` SET `birthdate` = NULL WHERE `birthdate` = '0000-00-00';
+
+INSERT INTO `sql_updates` (`timestamp`) VALUES (1467934919)
diff --git a/sql-files/upgrades/2016-07-08--02-51.sql b/sql-files/upgrades/2016-07-08--02-51.sql
new file mode 100644
index 000000000..8ecf1a25f
--- /dev/null
+++ b/sql-files/upgrades/2016-07-08--02-51.sql
@@ -0,0 +1,30 @@
+#1467935469
+
+-- This file is part of Hercules.
+-- http://herc.ws - http://github.com/HerculesWS/Hercules
+--
+-- Copyright (C) 2015-2016  Hercules Dev Team
+--
+-- Hercules is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+ALTER TABLE `atcommandlog` MODIFY `atcommand_date` DATETIME NULL;
+ALTER TABLE `branchlog` MODIFY `branch_date` DATETIME NULL;
+ALTER TABLE `chatlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `loginlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `mvplog` MODIFY `mvp_date` DATETIME NULL;
+ALTER TABLE `npclog` MODIFY `npc_date` DATETIME NULL;
+ALTER TABLE `picklog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `zenylog` MODIFY `time` DATETIME NULL;
+
+INSERT INTO `sql_updates` (`timestamp`) VALUES (1467935469)
diff --git a/sql-files/upgrades/eAthena-logs-upgrade.sql b/sql-files/upgrades/eAthena-logs-upgrade.sql
index 09ed4d8d0..014f119e3 100644
--- a/sql-files/upgrades/eAthena-logs-upgrade.sql
+++ b/sql-files/upgrades/eAthena-logs-upgrade.sql
@@ -42,3 +42,12 @@ ALTER TABLE `zenylog` MODIFY `type` ENUM('M','T','V','S','N','A','E','B','I','D'
 
 -- Add 'P' and 'C' types in `zenylog`
 ALTER TABLE `zenylog` MODIFY `type` ENUM('T','V','P','M','S','N','D','C','A','E','I','B') NOT NULL DEFAULT 'S';
+
+ALTER TABLE `atcommandlog` MODIFY `atcommand_date` DATETIME NULL;
+ALTER TABLE `branchlog` MODIFY `branch_date` DATETIME NULL;
+ALTER TABLE `chatlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `loginlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `mvplog` MODIFY `mvp_date` DATETIME NULL;
+ALTER TABLE `npclog` MODIFY `npc_date` DATETIME NULL;
+ALTER TABLE `picklog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `zenylog` MODIFY `time` DATETIME NULL;
diff --git a/sql-files/upgrades/eAthena-main-upgrade.sql b/sql-files/upgrades/eAthena-main-upgrade.sql
index 64b22bfe9..647c9e004 100644
--- a/sql-files/upgrades/eAthena-main-upgrade.sql
+++ b/sql-files/upgrades/eAthena-main-upgrade.sql
@@ -111,3 +111,17 @@ ALTER TABLE `inventory` CHANGE `nsiuid` `unique_id` BIGINT( 20 ) NOT NULL DEFAUL
 ALTER TABLE `mail` CHANGE `nsiuid` `unique_id` BIGINT( 20 ) NOT NULL DEFAULT '0';
 
 ALTER TABLE `storage` CHANGE `nsiuid` `unique_id` BIGINT( 20 ) NOT NULL DEFAULT '0';
+
+ALTER TABLE `charlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `interlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `ipbanlist` MODIFY `btime` DATETIME NULL;
+ALTER TABLE `ipbanlist` MODIFY `rtime` DATETIME NULL;
+ALTER TABLE `login` MODIFY `lastlogin` DATETIME NULL;
+ALTER TABLE `login` MODIFY `birthdate` DATE NULL;
+
+UPDATE `charlog` SET `time` = NULL WHERE `time` = '0000-00-00 00:00:00';
+UPDATE `interlog` SET `time` = NULL WHERE `time` = '0000-00-00 00:00:00';
+UPDATE `ipbanlist` SET `btime` = NULL WHERE `btime` = '0000-00-00 00:00:00';
+UPDATE `ipbanlist` SET `rtime` = NULL WHERE `rtime` = '0000-00-00 00:00:00';
+UPDATE `login` SET `lastlogin` = NULL WHERE `lastlogin` = '0000-00-00 00:00:00';
+UPDATE `login` SET `birthdate` = NULL WHERE `birthdate` = '0000-00-00';
diff --git a/sql-files/upgrades/index.txt b/sql-files/upgrades/index.txt
index 6e81bd199..b0347ab72 100644
--- a/sql-files/upgrades/index.txt
+++ b/sql-files/upgrades/index.txt
@@ -30,3 +30,5 @@
 2015-08-27--20-42.sql
 2015-12-17--15-58.sql
 2016-03-10--22-18.sql
+2016-07-08--02-42.sql
+2016-07-08--02-51.sql
diff --git a/sql-files/upgrades/rAthena-logs-upgrade.sql b/sql-files/upgrades/rAthena-logs-upgrade.sql
index 5e9dbf60c..09a571818 100644
--- a/sql-files/upgrades/rAthena-logs-upgrade.sql
+++ b/sql-files/upgrades/rAthena-logs-upgrade.sql
@@ -40,3 +40,11 @@ ALTER TABLE `picklog` MODIFY `card0` INT(11) NOT NULL DEFAULT '0';
 ALTER TABLE `picklog` MODIFY `card1` INT(11) NOT NULL DEFAULT '0';
 ALTER TABLE `picklog` MODIFY `card2` INT(11) NOT NULL DEFAULT '0';
 ALTER TABLE `picklog` MODIFY `card3` INT(11) NOT NULL DEFAULT '0';
+ALTER TABLE `atcommandlog` MODIFY `atcommand_date` DATETIME NULL;
+ALTER TABLE `branchlog` MODIFY `branch_date` DATETIME NULL;
+ALTER TABLE `chatlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `loginlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `mvplog` MODIFY `mvp_date` DATETIME NULL;
+ALTER TABLE `npclog` MODIFY `npc_date` DATETIME NULL;
+ALTER TABLE `picklog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `zenylog` MODIFY `time` DATETIME NULL;
diff --git a/sql-files/upgrades/rAthena-main-upgrade.sql b/sql-files/upgrades/rAthena-main-upgrade.sql
index e214e8d34..5dd6111a5 100644
--- a/sql-files/upgrades/rAthena-main-upgrade.sql
+++ b/sql-files/upgrades/rAthena-main-upgrade.sql
@@ -337,3 +337,16 @@ INSERT INTO `global_acc_reg_str_db` (`account_id`, `key`, `index`, `value`) SELE
 -- Dropping now useless table
 DROP TABLE `global_reg_value`;
 
+ALTER TABLE `charlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `interlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `ipbanlist` MODIFY `btime` DATETIME NULL;
+ALTER TABLE `ipbanlist` MODIFY `rtime` DATETIME NULL;
+ALTER TABLE `login` MODIFY `lastlogin` DATETIME NULL;
+ALTER TABLE `login` MODIFY `birthdate` DATE NULL;
+
+UPDATE `charlog` SET `time` = NULL WHERE `time` = '0000-00-00 00:00:00';
+UPDATE `interlog` SET `time` = NULL WHERE `time` = '0000-00-00 00:00:00';
+UPDATE `ipbanlist` SET `btime` = NULL WHERE `btime` = '0000-00-00 00:00:00';
+UPDATE `ipbanlist` SET `rtime` = NULL WHERE `rtime` = '0000-00-00 00:00:00';
+UPDATE `login` SET `lastlogin` = NULL WHERE `lastlogin` = '0000-00-00 00:00:00';
+UPDATE `login` SET `birthdate` = NULL WHERE `birthdate` = '0000-00-00';
-- 
cgit v1.2.3-70-g09d2

