Fixed offline messages bug
This commit is contained in:
		
							parent
							
								
									9ef9ce2b22
								
							
						
					
					
						commit
						885cf52bdc
					
				| @ -1 +1 @@ | ||||
| Subproject commit 7261d531f3c10be1437a4572369260aeff075e6c | ||||
| Subproject commit 99293e3af97cdc4041282a29495841b8ae3d2a4d | ||||
| @ -44,11 +44,10 @@ extern void testTomMath(); | ||||
|     #define DB_NAME "TeaData.sqlite" | ||||
| #endif | ||||
| 
 | ||||
| #include <regex> | ||||
| #include <codecvt> | ||||
| #include "src/client/music/internal_provider/channel_replay/ChannelProvider.h" | ||||
| 
 | ||||
| class CLIParser{ | ||||
| class CLIParser { | ||||
|     public: | ||||
|         CLIParser (int &argc, char **argv){ | ||||
|             for (int i = 1; i < argc; i++) | ||||
|  | ||||
| @ -44,7 +44,7 @@ if(!result && result.msg().find(ignore) == string::npos){ | ||||
| 
 | ||||
| #define RESIZE_COLUMN(tblName, rowName, size) up vote EXECUTE("Could not change column size", "ALTER TABLE " tblName " ALTER COLUMN " rowName " varchar(" size ")"); | ||||
| 
 | ||||
| #define CURRENT_DATABASE_VERSION 11 | ||||
| #define CURRENT_DATABASE_VERSION 12 | ||||
| #define CURRENT_PERMISSION_VERSION 4 | ||||
| 
 | ||||
| #define CLIENT_UID_LENGTH "64" | ||||
| @ -271,38 +271,38 @@ bool SqlDataManager::update_database(std::string &error) { | ||||
| 
 | ||||
|             case 7: | ||||
|                 /* recreate permission table */ | ||||
| /*
 | ||||
| DROP TABLE `permissions`, `properties`; | ||||
| ALTER TABLE permissions_v6 RENAME permissions; | ||||
| ALTER TABLE properties_v6 RENAME properties; | ||||
| */ | ||||
|                 /*
 | ||||
|                 DROP TABLE `permissions`, `properties`; | ||||
|                 ALTER TABLE permissions_v6 RENAME permissions; | ||||
|                 ALTER TABLE properties_v6 RENAME properties; | ||||
|                 */ | ||||
| 
 | ||||
|                 /* MySQL command
 | ||||
| 
 | ||||
| START TRANSACTION; | ||||
| SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; | ||||
|                 START TRANSACTION; | ||||
|                 SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; | ||||
| 
 | ||||
| -- Modify the permissions | ||||
| ALTER TABLE permissions RENAME TO permissions_v6; | ||||
| CREATE TABLE `permissions`(`serverId` INT NOT NULL, `type` INT, `id` INT, `channelId` INT, `permId` VARCHAR(256), `value` INT, `grant` INT, `flag_skip` TINYINT(1), `flag_negate` TINYINT(1), CONSTRAINT PK PRIMARY KEY(`serverId`, `type`, `id`, `channelId`, `permId`)) CHARACTER SET=utf8; | ||||
| CREATE INDEX `idx_permissions_serverId` ON `permissions` (`serverId`); | ||||
| CREATE INDEX `idx_permissions_serverId_channelId` ON `permissions` (`serverId`, `channelId`); | ||||
| INSERT INTO `permissions` SELECT * FROM `permissions_v6` GROUP BY `serverId`, `type`, `id`, `channelId`, `permId`; | ||||
|                 -- Modify the permissions | ||||
|                 ALTER TABLE permissions RENAME TO permissions_v6; | ||||
|                 CREATE TABLE `permissions`(`serverId` INT NOT NULL, `type` INT, `id` INT, `channelId` INT, `permId` VARCHAR(256), `value` INT, `grant` INT, `flag_skip` TINYINT(1), `flag_negate` TINYINT(1), CONSTRAINT PK PRIMARY KEY(`serverId`, `type`, `id`, `channelId`, `permId`)) CHARACTER SET=utf8; | ||||
|                 CREATE INDEX `idx_permissions_serverId` ON `permissions` (`serverId`); | ||||
|                 CREATE INDEX `idx_permissions_serverId_channelId` ON `permissions` (`serverId`, `channelId`); | ||||
|                 INSERT INTO `permissions` SELECT * FROM `permissions_v6` GROUP BY `serverId`, `type`, `id`, `channelId`, `permId`; | ||||
| 
 | ||||
| -- Modify the properties | ||||
| ALTER TABLE properties RENAME TO properties_v6; | ||||
| CREATE TABLE properties(`serverId` INTEGER DEFAULT -1, `type` INTEGER, `id` INTEGER, `key` VARCHAR(256), `value` TEXT, CONSTRAINT PK PRIMARY KEY (`serverId`, `type`, `id`, `key`)) CHARACTER SET=utf8; | ||||
| CREATE INDEX `idx_properties_serverId` ON `properties` (`serverId`); | ||||
| CREATE INDEX `idx_properties_serverId_id` ON `properties` (`serverId`, `id`); | ||||
| INSERT INTO `properties` SELECT * FROM `properties_v6` GROUP BY `serverId`, `type`, `id`, `key`; | ||||
|                 -- Modify the properties | ||||
|                 ALTER TABLE properties RENAME TO properties_v6; | ||||
|                 CREATE TABLE properties(`serverId` INTEGER DEFAULT -1, `type` INTEGER, `id` INTEGER, `key` VARCHAR(256), `value` TEXT, CONSTRAINT PK PRIMARY KEY (`serverId`, `type`, `id`, `key`)) CHARACTER SET=utf8; | ||||
|                 CREATE INDEX `idx_properties_serverId` ON `properties` (`serverId`); | ||||
|                 CREATE INDEX `idx_properties_serverId_id` ON `properties` (`serverId`, `id`); | ||||
|                 INSERT INTO `properties` SELECT * FROM `properties_v6` GROUP BY `serverId`, `type`, `id`, `key`; | ||||
| 
 | ||||
| -- Delete orphaned permissions and properties | ||||
| DELETE FROM `permissions` WHERE (`type` = 1 OR `type` = 2) AND NOT ((`serverId`, `channelId`) IN (SELECT `serverId`, `channelId` FROM `channels`) OR `channelId` = 0); | ||||
| DELETE FROM `permissions` WHERE `type` = 0 AND NOT (`serverId`, `id`) IN (SELECT `serverId`, `groupId` FROM `groups`); | ||||
| DELETE FROM `permissions` WHERE `type` = 2 AND NOT (`serverId`, `id`) IN (SELECT `serverId`, `cldbid` FROM `clients`); | ||||
| DELETE FROM `properties` WHERE `type` = 1 AND NOT (`serverId` IN (SELECT `serverId` FROM servers) OR `serverId` = 0); | ||||
|                 -- Delete orphaned permissions and properties | ||||
|                 DELETE FROM `permissions` WHERE (`type` = 1 OR `type` = 2) AND NOT ((`serverId`, `channelId`) IN (SELECT `serverId`, `channelId` FROM `channels`) OR `channelId` = 0); | ||||
|                 DELETE FROM `permissions` WHERE `type` = 0 AND NOT (`serverId`, `id`) IN (SELECT `serverId`, `groupId` FROM `groups`); | ||||
|                 DELETE FROM `permissions` WHERE `type` = 2 AND NOT (`serverId`, `id`) IN (SELECT `serverId`, `cldbid` FROM `clients`); | ||||
|                 DELETE FROM `properties` WHERE `type` = 1 AND NOT (`serverId` IN (SELECT `serverId` FROM servers) OR `serverId` = 0); | ||||
| 
 | ||||
| ROLLBACK; | ||||
|                 ROLLBACK; | ||||
|                  */ | ||||
|                 if(manager->getType() == sql::TYPE_MYSQL) { | ||||
|                     /*
 | ||||
| @ -477,6 +477,14 @@ ROLLBACK; | ||||
|                 } | ||||
|                 db_version(12); | ||||
| #endif | ||||
|             case 11: | ||||
|                 result = sql::command(this->sql(), "UPDATE TABLE `letters` SET `created` TO 0 WHERE 1;").execute(); | ||||
|                 if(!result) { | ||||
|                     error = "Failed to reset offline messages timestamps"; | ||||
|                     return false; | ||||
|                 } | ||||
| 
 | ||||
|                 db_version(12); | ||||
|             default: | ||||
|                 break; | ||||
|         } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user