Hangfire.MySqlStorage
Hangfire.MySqlStorage copied to clipboard
"#1071 - Specified key was too long; max key length is 767 bytes
CREATE TABLE `Set` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`Key` varchar(100) NOT NULL,
`Value` varchar(256) NOT NULL,
`Score` float NOT NULL,
`ExpireAt` datetime DEFAULT NULL,
PRIMARY KEY (`Id`),
UNIQUE KEY `IX_Set_Key_Value` (`Key`,`Value`)
) ENGINE=InnoDB CHARSET=utf8;
The problem occurs with MySql 5.6 on db initialization. It appears that varchar(256) is the offender, if it is changed to varchar(255) it executes correctly.
No pull request as I'm not sure if 256 is strictly required.
I have this issue too, it occurs on MySql 5.6 on a Windows installation
I can confirm I am also getting this problem with V2.0.0 of Hangfire.MySqlStorage and MySql 5.6.41
Got the same issue and found a workaround. Got the install.sql file from the former release (1.0.5) and run to create folder structure before running the program. The charset is different (latin1) but can be changed later if necessary.
https://raw.githubusercontent.com/arnoldasgudas/Hangfire.MySqlStorage/5d91c44e58ceb11b67ac733287172550e301bc8c/Hangfire.MySql/Install.sql
we can update install.sql like this:
-- ----------------------------
-- Table structure for `Set`
-- ----------------------------
CREATE TABLE `[tablesPrefix]Set` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`Key` nvarchar(100) NOT NULL,
`Value` nvarchar(100) NOT NULL,
`Score` float NOT NULL,
`ExpireAt` datetime DEFAULT NULL,
PRIMARY KEY (`Id`),
UNIQUE KEY `IX_[tablesPrefix]Set_Key_Value` (`Key`,`Value`)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
then excute install.sql on MySql 5.6 without no error.
and set PrepareSchemaIfNecessary = false
Works like a charm, life saving workaround, thanks