Index: branches/5.2.x/core/install/upgrades.sql
===================================================================
diff -u -N -r14994 -r15012
--- branches/5.2.x/core/install/upgrades.sql	(.../upgrades.sql)	(revision 14994)
+++ branches/5.2.x/core/install/upgrades.sql	(.../upgrades.sql)	(revision 15012)
@@ -2399,7 +2399,7 @@
 DELETE FROM PersistantSessionData
 WHERE VariableName LIKE 'agent%';
 
-RENAME TABLE Agents TO ScheduledTasks;
+RENAME TABLE <%TABLE_PREFIX%>Agents TO <%TABLE_PREFIX%>ScheduledTasks;
 
 ALTER TABLE ScheduledTasks
 	CHANGE AgentId ScheduledTaskId INT(11) NOT NULL AUTO_INCREMENT,
@@ -2526,9 +2526,71 @@
 
 INSERT INTO ConfigurationValues VALUES(DEFAULT, 'UpdateCountersOnFilterChange', '1', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_UpdateCountersOnFilterChange', 'checkbox', '', '', 10.15, 0, 0, NULL);
 
-ALTER TABLE UserSession CHANGE `tz` `TimeZone` VARCHAR(255) NOT NULL;
+# use new table name (see /core/install.php:390)!
+ALTER TABLE UserSessions CHANGE `tz` `TimeZone` VARCHAR(255) NOT NULL;
 ALTER TABLE PortalUser CHANGE `tz` `TimeZone` VARCHAR(255) NOT NULL DEFAULT '';
 
 UPDATE SearchConfig
 SET FieldName = 'TimeZone'
 WHERE FieldName = 'tz' AND TableName = 'PortalUser';
+
+RENAME TABLE <%TABLE_PREFIX%>BanRules TO <%TABLE_PREFIX%>UserBanRules;
+RENAME TABLE <%TABLE_PREFIX%>Cache TO <%TABLE_PREFIX%>SystemCache;
+RENAME TABLE <%TABLE_PREFIX%>ConfigurationValues TO <%TABLE_PREFIX%>SystemSettings;
+RENAME TABLE <%TABLE_PREFIX%>Category TO <%TABLE_PREFIX%>Categories;
+
+UPDATE ItemTypes SET SourceTable = 'Categories' WHERE ItemType = 1;
+UPDATE ItemTypes SET SourceTable = 'Users' WHERE ItemType = 6;
+
+UPDATE SearchConfig SET TableName = 'Categories' WHERE TableName = 'Category';
+UPDATE SearchConfig SET TableName = 'CustomFields' WHERE TableName = 'CustomField';
+UPDATE SearchConfig SET TableName = 'Users' WHERE TableName = 'PortalUser';
+
+UPDATE StatItem SET ValueSQL = REPLACE(ValueSQL, '<%prefix%>Category', '<%prefix%>Categories');
+UPDATE StatItem SET ValueSQL = REPLACE(ValueSQL, '<%prefix%>ItemReview', '<%prefix%>CatalogReviews');
+UPDATE StatItem SET ValueSQL = REPLACE(ValueSQL, '<%prefix%>Language', '<%prefix%>Languages');
+UPDATE StatItem SET ValueSQL = REPLACE(ValueSQL, '<%prefix%>PortalGroup', '<%prefix%>UserGroups');
+UPDATE StatItem SET ValueSQL = REPLACE(ValueSQL, '<%prefix%>PortalUser', '<%prefix%>Users');
+UPDATE StatItem SET ValueSQL = REPLACE(ValueSQL, '<%prefix%>Theme', '<%prefix%>Themes');
+UPDATE StatItem SET ValueSQL = REPLACE(ValueSQL, '<%prefix%>UserSession', '<%prefix%>UserSessions');
+
+UPDATE SystemSettings SET ValueList = REPLACE(ValueList, '<PREFIX>CustomField', '<PREFIX>CustomFields');
+UPDATE SystemSettings SET ValueList = REPLACE(ValueList, '<PREFIX>PortalGroup', '<PREFIX>UserGroups');
+
+UPDATE Counters
+SET CountQuery = 'SELECT COUNT(*) FROM <%PREFIX%>Users WHERE Status = 1', TablesAffected = '|Users|'
+WHERE `Name` = 'members_count';
+
+UPDATE Counters
+SET
+	CountQuery = REPLACE(CountQuery, '<%PREFIX%>UserSession', '<%PREFIX%>UserSessions'),
+	TablesAffected = REPLACE(TablesAffected, '|UserSession|', '|UserSessions|');
+
+RENAME TABLE <%TABLE_PREFIX%>CustomField TO <%TABLE_PREFIX%>CustomFields;
+RENAME TABLE <%TABLE_PREFIX%>Drafts TO <%TABLE_PREFIX%>FormSubmissionReplyDrafts;
+RENAME TABLE <%TABLE_PREFIX%>Events TO <%TABLE_PREFIX%>EmailEvents;
+
+DELETE FROM PersistantSessionData WHERE VariableName LIKE '%custom_filter%';
+
+RENAME TABLE <%TABLE_PREFIX%>Favorites TO <%TABLE_PREFIX%>UserFavorites;
+RENAME TABLE <%TABLE_PREFIX%>Images TO <%TABLE_PREFIX%>CatalogImages;
+RENAME TABLE <%TABLE_PREFIX%>ItemFiles TO <%TABLE_PREFIX%>CatalogFiles;
+RENAME TABLE <%TABLE_PREFIX%>ItemRating TO <%TABLE_PREFIX%>CatalogRatings;
+RENAME TABLE <%TABLE_PREFIX%>ItemReview TO <%TABLE_PREFIX%>CatalogReviews;
+RENAME TABLE <%TABLE_PREFIX%>Language TO <%TABLE_PREFIX%>Languages;
+RENAME TABLE <%TABLE_PREFIX%>PermCache TO <%TABLE_PREFIX%>CategoryPermissionsCache;
+RENAME TABLE <%TABLE_PREFIX%>PermissionConfig TO <%TABLE_PREFIX%>CategoryPermissionsConfig;
+RENAME TABLE <%TABLE_PREFIX%>Phrase TO <%TABLE_PREFIX%>LanguageLabels;
+RENAME TABLE <%TABLE_PREFIX%>PortalGroup TO <%TABLE_PREFIX%>UserGroups;
+RENAME TABLE <%TABLE_PREFIX%>PersistantSessionData TO <%TABLE_PREFIX%>UserPersistentSessionData;
+RENAME TABLE <%TABLE_PREFIX%>PortalUser TO <%TABLE_PREFIX%>Users;
+RENAME TABLE <%TABLE_PREFIX%>PortalUserCustomData TO <%TABLE_PREFIX%>UserCustomData;
+RENAME TABLE <%TABLE_PREFIX%>RelatedSearches TO <%TABLE_PREFIX%>CategoryRelatedSearches;
+RENAME TABLE <%TABLE_PREFIX%>Relationship TO <%TABLE_PREFIX%>CatalogRelationships;
+RENAME TABLE <%TABLE_PREFIX%>SearchLog TO <%TABLE_PREFIX%>SearchLogs;
+RENAME TABLE <%TABLE_PREFIX%>Skins TO <%TABLE_PREFIX%>AdminSkins;
+RENAME TABLE <%TABLE_PREFIX%>SubmissionLog TO <%TABLE_PREFIX%>FormSubmissionReplies;
+RENAME TABLE <%TABLE_PREFIX%>Theme TO <%TABLE_PREFIX%>Themes;
+RENAME TABLE <%TABLE_PREFIX%>UserGroup TO <%TABLE_PREFIX%>UserGroupRelations;
+RENAME TABLE <%TABLE_PREFIX%>Visits TO <%TABLE_PREFIX%>UserVisits;
+RENAME TABLE <%TABLE_PREFIX%>SessionLogs TO <%TABLE_PREFIX%>UserSessionLogs;
