From b6dc90e3f658a8201424aafec8e304c74d981022 Mon Sep 17 00:00:00 2001
From: BlueRaja <BlueRaja.admin@gmail.com>
Date: Thu, 24 Jan 2013 03:04:26 -0600
Subject: Added a 'mapExpireTime' column to mapOfTheDay table, to simply a lot
 of SQL

---
 db updates.sql | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

(limited to 'db updates.sql')

diff --git a/db updates.sql b/db updates.sql
index b8b63a2..440f473 100644
--- a/db updates.sql	
+++ b/db updates.sql	
@@ -1,4 +1,4 @@
-ALTER TABLE `db428221563`.`mapOfTheDay` DROP INDEX `UniqueTypeDate` ,
+ALTER TABLE `mapOfTheDay` DROP INDEX `UniqueTypeDate` ,
 ADD UNIQUE `UniqueTypeDate` ( `mapDate` , `mapType` );
 
 ALTER TABLE `mapOfTheDay` ADD `championPointsWorth` INT NOT NULL DEFAULT '0';
@@ -6,4 +6,19 @@ ALTER TABLE `mapOfTheDay` ADD `championPointsWorth` INT NOT NULL DEFAULT '0';
 ALTER TABLE `users` ADD `totalMazes` INT NOT NULL DEFAULT '0',
 ADD `totalMoves` INT NOT NULL DEFAULT '0';
 
-ALTER TABLE `solutions` ADD `isTiedForHighScore` BOOLEAN NOT NULL DEFAULT '0';
\ No newline at end of file
+ALTER TABLE `solutions` ADD `isTiedForHighScore` BOOLEAN NOT NULL DEFAULT '0';
+
+-- Add the 'mapExpireTime' column
+ALTER TABLE `mapOfTheDay` ADD `mapExpireTime` DATETIME NULL DEFAULT NULL AFTER `mapDate`;
+
+UPDATE mapOfTheDay
+SET mapExpireTime = DATE_ADD(mapDate, INTERVAL 1 DAY)
+WHERE mapType <> 5;
+
+UPDATE mapOfTheDay
+SET mapExpireTime = DATE_ADD(mapDate, INTERVAL 2 DAY)
+WHERE mapType = 5;
+
+ALTER TABLE `mapOfTheDay` CHANGE `mapExpireTime` `mapExpireTime` DATETIME NOT NULL;
+
+ALTER TABLE `mapOfTheDay` ADD INDEX ( `mapExpireTime` , `mapType` );
\ No newline at end of file
-- 
cgit v1.2.3

