Permalink
Browse files

MySQL - a bug while adding primary keys was fixed. Added some new pri…

…mary keys.
  • Loading branch information...
1 parent 3c350e9 commit aac9c92b43f57132db4b19a2025b459164e20fc1 @vzrus committed Apr 13, 2012
@@ -72,14 +72,14 @@ IF (SELECT COUNT(1) FROM INFORMATION_SCHEMA.STATISTICS S WHERE S.TABLE_SCHEMA='{
ALTER TABLE {databaseName}.{objectQualifier}Thanks
ADD UNIQUE INDEX `IX_{databaseName}_{objectQualifier}Thanks_UserID` (`ThanksFromUserID`, `ThanksToUserID`);
-END IF; */
+END IF;
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS S WHERE S.TABLE_SCHEMA='{databaseName}' AND S.INDEX_NAME='IX_{databaseName}_{objectQualifier}ActiveAccess_UserID_Forum' AND S.TABLE_NAME=LOWER('{objectQualifier}ActiveAccess') AND (S.COLUMN_NAME='UserID' OR S.COLUMN_NAME='ForumID') LIMIT 1) THEN
ALTER TABLE {databaseName}.{objectQualifier}ActiveAccess
ADD UNIQUE INDEX `IX_{databaseName}_{objectQualifier}ActiveAccess_UserID_Forum` (`UserID`,`ForumID`);
-END IF;
+END IF;*/
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS S WHERE S.TABLE_SCHEMA='{databaseName}' AND S.INDEX_NAME='IX_{databaseName}_{objectQualifier}MessageHistory_Edited_MessageID' AND S.TABLE_NAME=LOWER('{objectQualifier}MessageHistory') AND (S.COLUMN_NAME='Edited' OR S.COLUMN_NAME='MessageID') LIMIT 1) THEN
@@ -22,14 +22,14 @@ AND T.CONSTRAINT_NAME = 'PRIMARY') THEN
set @pk_t_name = pk_t_name ;
set @pk_c_name = pk_c_name ;
-
+set @pk_c2_name = pk_c2_name ;
if pk_c2_name is null then
set @fk_create_string = concat('ALTER TABLE {databaseName}.{objectQualifier}',
@pk_t_name,' ADD PRIMARY KEY (`',@pk_c_name,'`);');
else
set @fk_create_string = concat('ALTER TABLE {databaseName}.{objectQualifier}',
-@pk_t_name,' ADD PRIMARY KEY (`',@pk_c_name,'`,`',@pk_c_name,'`);');
+@pk_t_name,' ADD PRIMARY KEY (`',@pk_c_name,'`,`',@pk_c2_name,'`);');
end if;
prepare fk_check_statement from @fk_create_string ;
@@ -138,7 +138,24 @@ CALL {databaseName}.{objectQualifier}add_or_check_pkeys('WatchForum','INT NOT N
CALL {databaseName}.{objectQualifier}add_or_check_pkeys('WatchTopic','INT NOT NULL AUTO_INCREMENT','WatchTopicID', null);
--GO
-
+CALL {databaseName}.{objectQualifier}add_or_check_pkeys('ActiveAccess',null,'UserID', 'ForumID');
+--GO
+CALL {databaseName}.{objectQualifier}add_or_check_pkeys('UserProfile',null,'UserID', 'ApplicationName');
+--GO
+CALL {databaseName}.{objectQualifier}add_or_check_pkeys('ForumReadTracking',null,'UserID', 'ForumID');
+--GO
+CALL {databaseName}.{objectQualifier}add_or_check_pkeys('TopicReadTracking',null,'UserID', 'TopicID');
+--GO
+CALL {databaseName}.{objectQualifier}add_or_check_pkeys('GroupMedal',null,'MedalID', 'GroupID');
+--GO
+CALL {databaseName}.{objectQualifier}add_or_check_pkeys('UserMedal',null,'MedalID', 'UserID');
+--GO
+CALL {databaseName}.{objectQualifier}add_or_check_pkeys('MessageHistory',null,'MessageID', 'Edited');
+--GO
+CALL {databaseName}.{objectQualifier}add_or_check_pkeys('MessageReported',null,'MessageID',null);
+--GO
+CALL {databaseName}.{objectQualifier}add_or_check_pkeys('MessageReportedAudit',null,'LogID',null);
+--GO
DROP PROCEDURE IF EXISTS {databaseName}.{objectQualifier}add_or_check_pkeys;
--GO
@@ -12959,6 +12959,7 @@ begin
usr.UserId,
usr.Name AS UserName,
usr.DisplayName AS UserDisplayName,
+ usr.LastVisit,
0 as IsCrawler,
1 as UserCount,
-- IsActiveExcluded
@@ -1489,6 +1489,33 @@ IF EXISTS (SELECT 1 FROM information_schema.COLUMNS
ALTER TABLE {databaseName}.{objectQualifier}ForumReadtracking DROP PRIMARY KEY;
ALTER TABLE {databaseName}.{objectQualifier}ForumReadtracking DROP `TrackingID`;
END IF;
+IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS S WHERE S.TABLE_SCHEMA='{databaseName}' AND S.INDEX_NAME='IX_{databaseName}_{objectQualifier}ActiveAccess_UserID_Forum' AND S.TABLE_NAME=LOWER('{objectQualifier}ActiveAccess') AND (S.COLUMN_NAME='UserID' OR S.COLUMN_NAME='ForumID') LIMIT 1) THEN
+
+ALTER TABLE {databaseName}.{objectQualifier}ActiveAccess
+DROP INDEX `IX_{databaseName}_{objectQualifier}ActiveAccess_UserID_Forum`;
+
+END IF;
+
+IF EXISTS (SELECT 1 FROM information_schema.COLUMNS
+ WHERE LOWER(TABLE_SCHEMA)=LOWER('{databaseName}') AND
+ LOWER(TABLE_NAME)=LOWER('{objectQualifier}MessageReportedAudit')
+ AND COLUMN_NAME='MessageID' AND IS_NULLABLE='YES' LIMIT 1) THEN
+ ALTER TABLE {databaseName}.{objectQualifier}MessageReportedAudit CHANGE `MessageID` `MessageID` INT NOT NULL;
+ END IF;
+
+ IF EXISTS (SELECT 1 FROM information_schema.COLUMNS
+ WHERE LOWER(TABLE_SCHEMA)=LOWER('{databaseName}') AND
+ LOWER(TABLE_NAME)=LOWER('{objectQualifier}MessageReportedAudit')
+ AND COLUMN_NAME='UserID' AND IS_NULLABLE='YES' LIMIT 1) THEN
+ ALTER TABLE {databaseName}.{objectQualifier}MessageReportedAudit CHANGE `UserID` `UserID` INT NOT NULL;
+ END IF;
+
+ IF EXISTS (SELECT 1 FROM information_schema.COLUMNS
+ WHERE LOWER(TABLE_SCHEMA)=LOWER('{databaseName}') AND
+ LOWER(TABLE_NAME)=LOWER('{objectQualifier}MessageReportedAudit')
+ AND COLUMN_NAME='Reported' AND IS_NULLABLE='YES' LIMIT 1) THEN
+ ALTER TABLE {databaseName}.{objectQualifier}MessageReportedAudit CHANGE `Reported` `Reported` DATETIME NOT NULL;
+ END IF;
END;
--GO

0 comments on commit aac9c92

Please sign in to comment.