From 35dfdc948211d422d52b98a93407c56ac5a67448 Mon Sep 17 00:00:00 2001
From: git <BlueRaja.admin@gmail.com>
Date: Thu, 21 Feb 2013 02:51:02 -0600
Subject: Fixing DB updates to grab names of complex maps as well

---
 db updates.sql | 43 +++++++++++++++++++++----------------------
 1 file changed, 21 insertions(+), 22 deletions(-)

(limited to 'db updates.sql')

diff --git a/db updates.sql b/db updates.sql
index 100c9ed..938e46d 100644
--- a/db updates.sql	
+++ b/db updates.sql	
@@ -58,46 +58,45 @@ DROP TABLE `userData`;
 ALTER TABLE `users` ADD `dateChatGaggedUntil` DATETIME NULL ,
 ADD `isOptedOutOfEmails` BOOLEAN NOT NULL DEFAULT '0';
 
--- Set the name column in maps table
+-- Most special maps (and some others) have the map-name in the map code.  Copy it to the name column.
+UPDATE maps
+INNER JOIN
+(
+    -- Get the code substring, starting at the map name
+    SELECT SUBSTRING(code, LENGTH(SUBSTRING_INDEX(code, '.', 5))+2) AS codeSubstring, Id
+    FROM (SELECT code, Id FROM maps) AS mapsInner
+) AS mapsOuter ON maps.Id = mapsOuter.Id
+INNER JOIN mapOfTheDay ON maps.Id = mapOfTheDay.mapId
+SET maps.name = SUBSTRING(codeSubstring, 1, INSTR(codeSubstring, ':')-2)
+WHERE maps.name IS NULL;
+
+-- Rename the remaining maps
 UPDATE maps
 INNER JOIN mapOfTheDay ON maps.Id = mapOfTheDay.mapId
 SET maps.name = 'Simple'
 WHERE mapOfTheDay.mapType = 1
-AND maps.name IS NULL;
+AND (maps.name IS NULL OR maps.name = '');
 
 UPDATE maps
 INNER JOIN mapOfTheDay ON maps.Id = mapOfTheDay.mapId
 SET maps.name = 'Normal'
 WHERE mapOfTheDay.mapType = 2
-AND maps.name IS NULL;
+AND (maps.name IS NULL OR maps.name = '');
 
 UPDATE maps
 INNER JOIN mapOfTheDay ON maps.Id = mapOfTheDay.mapId
 SET maps.name = 'Complex'
 WHERE mapOfTheDay.mapType = 3
-AND maps.name IS NULL;
-
-UPDATE maps
-INNER JOIN mapOfTheDay ON maps.Id = mapOfTheDay.mapId
-SET maps.name = 'Ultra Complex'
-WHERE mapOfTheDay.mapType = 5
-AND maps.name IS NULL;
+AND (maps.name IS NULL OR maps.name = '');
 
--- Most special maps (and some others) have the map-name in the map code.  Copy it to the name column.
 UPDATE maps
-INNER JOIN
-(
-    -- Get the code substring, starting at the map name
-    SELECT SUBSTRING(code, LENGTH(SUBSTRING_INDEX(code, '.', 5))+2) AS codeSubstring, Id
-    FROM (SELECT code, Id FROM maps) AS mapsInner
-) AS mapsOuter ON maps.Id = mapsOuter.Id
 INNER JOIN mapOfTheDay ON maps.Id = mapOfTheDay.mapId
-SET maps.name = SUBSTRING(codeSubstring, 1, INSTR(codeSubstring, ':')-2)
-WHERE maps.name IS NULL;
+SET maps.name = 'Special'
+WHERE mapOfTheDay.mapType = 4
+AND (maps.name IS NULL OR maps.name = '');
 
--- Rename the remaining special maps
 UPDATE maps
 INNER JOIN mapOfTheDay ON maps.Id = mapOfTheDay.mapId
-SET maps.name = 'Special'
-WHERE mapOfTheDay.mapType = 4
+SET maps.name = 'Ultra Complex'
+WHERE mapOfTheDay.mapType = 5
 AND (maps.name IS NULL OR maps.name = '');
\ No newline at end of file
-- 
cgit v1.2.3

