ALTER TABLE Cache ADD LifeTime INT NOT NULL DEFAULT '-1';
ALTER TABLE ConfigurationAdmin CHANGE DisplayOrder DisplayOrder DOUBLE NOT NULL DEFAULT '0';
ALTER TABLE ConfigurationAdmin ADD GroupDisplayOrder DOUBLE NOT NULL AFTER DisplayOrder;

UPDATE ConfigurationAdmin SET DisplayOrder = '10.01', GroupDisplayOrder = 1 WHERE VariableName = 'Category_Sortfield';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.01', GroupDisplayOrder = 2 WHERE VariableName = 'Category_Sortorder';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.02', GroupDisplayOrder = 1 WHERE VariableName = 'Category_Sortfield2';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.02', GroupDisplayOrder = 2 WHERE VariableName = 'Category_Sortorder2';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.03' WHERE VariableName = 'Perpage_Category';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.04' WHERE VariableName = 'Perpage_Category_Short';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.05' WHERE VariableName = 'Category_DaysNew';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.06' WHERE VariableName = 'Category_ShowPick';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.07' WHERE VariableName = 'Root_Name';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.08' WHERE VariableName = 'MaxImportCategoryLevels';
UPDATE ConfigurationAdmin SET DisplayOrder = '20.01' WHERE VariableName = 'Category_MetaKey';
UPDATE ConfigurationAdmin SET DisplayOrder = '20.02' WHERE VariableName = 'Category_MetaDesc';

UPDATE ConfigurationAdmin SET DisplayOrder = '10.01' WHERE VariableName = 'User_Allow_New';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.02' WHERE VariableName = 'Email_As_Login';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.03' WHERE VariableName = 'Min_UserName';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.04' WHERE VariableName = 'Min_Password';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.05' WHERE VariableName = 'Users_AllowReset';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.06' WHERE VariableName = 'User_Password_Auto';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.07' WHERE VariableName = 'User_MembershipExpirationReminder';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.08' WHERE VariableName = 'User_NewGroup';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.09' WHERE VariableName = 'User_LoggedInGroup';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.10' WHERE VariableName = 'User_GuestGroup';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.11' WHERE VariableName = 'User_SubscriberGroup';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.12' WHERE VariableName = 'RootPass';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.13' WHERE VariableName = 'RootPassVerify';
UPDATE ConfigurationAdmin SET DisplayOrder = '20.01' WHERE VariableName = 'User_Votes_Deny';
UPDATE ConfigurationAdmin SET DisplayOrder = '20.02' WHERE VariableName = 'User_Review_Deny';

UPDATE ConfigurationAdmin SET DisplayOrder = '10.01' WHERE VariableName = 'Site_Path';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.02' WHERE VariableName = 'Site_Name';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.03' WHERE VariableName = 'CookieSessions';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.04' WHERE VariableName = 'SessionCookieName';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.05' WHERE VariableName = 'SessionTimeout';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.06' WHERE VariableName = 'SessionReferrerCheck';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.07' WHERE VariableName = 'SystemTagCache';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.08' WHERE VariableName = 'SocketBlockingMode';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.09' WHERE VariableName = 'SSL_URL';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.10' WHERE VariableName = 'Require_SSL';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.11' WHERE VariableName = 'Force_HTTP_When_SSL_Not_Required';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.12' WHERE VariableName = 'UseModRewrite';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.13' WHERE VariableName = 'UseModRewriteWithSSL';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.14' WHERE VariableName = 'UseJSRedirect';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.15' WHERE VariableName = 'UseCronForRegularEvent';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.16' WHERE VariableName = 'ErrorTemplate';
UPDATE ConfigurationAdmin SET DisplayOrder = '10.17' WHERE VariableName = 'NoPermissionTemplate';
UPDATE ConfigurationAdmin SET DisplayOrder = '20.01' WHERE VariableName = 'Config_Server_Time';
UPDATE ConfigurationAdmin SET DisplayOrder = '20.02' WHERE VariableName = 'Config_Site_Time';
UPDATE ConfigurationAdmin SET DisplayOrder = '20.03' WHERE VariableName = 'FirstDayOfWeek';
UPDATE ConfigurationAdmin SET DisplayOrder = '30.01' WHERE VariableName = 'Smtp_Server';
UPDATE ConfigurationAdmin SET DisplayOrder = '30.02' WHERE VariableName = 'Smtp_Port';
UPDATE ConfigurationAdmin SET DisplayOrder = '30.03' WHERE VariableName = 'Smtp_Authenticate';
UPDATE ConfigurationAdmin SET DisplayOrder = '30.04' WHERE VariableName = 'Smtp_User';
UPDATE ConfigurationAdmin SET DisplayOrder = '30.05' WHERE VariableName = 'Smtp_Pass';
UPDATE ConfigurationAdmin SET DisplayOrder = '30.06' WHERE VariableName = 'Smtp_DefaultHeaders';
UPDATE ConfigurationAdmin SET DisplayOrder = '30.07' WHERE VariableName = 'Smtp_AdminMailFrom';
UPDATE ConfigurationAdmin SET DisplayOrder = '40.01' WHERE VariableName = 'Backup_Path';

ALTER TABLE Category ADD COLUMN l1_Name varchar(255) NOT NULL default '' AFTER Name, ADD INDEX (l1_Name(5)), ADD COLUMN l2_Name varchar(255) NOT NULL default '' AFTER l1_Name, ADD INDEX (l2_Name(5)), ADD COLUMN l3_Name varchar(255) NOT NULL default '' AFTER l2_Name, ADD INDEX (l3_Name(5)), ADD COLUMN l4_Name varchar(255) NOT NULL default '' AFTER l3_Name, ADD INDEX (l4_Name(5)), ADD COLUMN l5_Name varchar(255) NOT NULL default '' AFTER l4_Name, ADD INDEX (l5_Name(5)), ADD COLUMN l1_Description text NOT NULL AFTER Description, ADD INDEX (l1_Description(5)), ADD COLUMN l2_Description text NOT NULL AFTER l1_Description, ADD INDEX (l2_Description(5)), ADD COLUMN l3_Description text NOT NULL AFTER l2_Description, ADD INDEX (l3_Description(5)), ADD COLUMN l4_Description text NOT NULL AFTER l3_Description, ADD INDEX (l4_Description(5)), ADD COLUMN l5_Description text NOT NULL AFTER l4_Description, ADD INDEX (l5_Description(5));

ALTER TABLE Permissions ADD UNIQUE PermIndex (Permission, GroupId, CatId, Type);
REPLACE INTO Permissions (Permission, GroupId, PermissionValue, Type, CatId) VALUES ('CATEGORY.VIEW', 11, 1, 0, 0);


UPDATE Modules SET Version = '1.2.1' WHERE Name = 'In-Portal';