Closed truedays closed 7 years ago
Hi, Looks the example schema given in Readme is wrong. Can you please try this schema and see if it works?
CREATE TABLE IF NOT EXISTS `new_mail` (
`mail_id` BIGINT(20) unsigned NOT NULL AUTO_INCREMENT,
`date` datetime NOT NULL,
`from` varchar(128) character set latin1 NOT NULL,
`to` varchar(128) character set latin1 NOT NULL,
`subject` varchar(255) NOT NULL,
`body` text NOT NULL,
`charset` varchar(32) character set latin1 NOT NULL,
`mail` longblob NOT NULL,
`spam_score` float NOT NULL,
`hash` char(32) character set latin1 NOT NULL,
`content_type` varchar(64) character set latin1 NOT NULL,
`recipient` varchar(128) character set latin1 NOT NULL,
`has_attach` int(11) NOT NULL,
`ip_addr` varchar(15) NOT NULL,
`return_path` VARCHAR(255) NOT NULL,
`is_tls` BIT(1) DEFAULT b'0' NOT NULL,
PRIMARY KEY (`mail_id`),
KEY `to` (`to`),
KEY `hash` (`hash`),
KEY `date` (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Hi @flashmob ,
With that schema I get:
FATA[0000] failed while db.Prepare(UPDATE...) error="Received #1146 error from MySQL server: \"Table 'gmail.gm2_setting' doesn't exist\""
You'll need to create one more table:
CREATE TABLE gm2_setting
(
setting_name VARCHAR(250) NOT NULL,
setting_value TEXT,
site_id INT(11) DEFAULT '1' NOT NULL
);
CREATE INDEX setting_name ON gm2_setting (setting_name);
and then:
insert into gm2_setting (setting_name), ('received_emails')
The SQL CREATE Adding the _gm2setting table fixed my issue. :+1:
The subsequent SQL INSERT didn't work, but everything seems functional even with no data in that table. :thinking:
Looking into it more, it looks like the SQL code in this file is outdated and different to what we have in prod. We no longer use the gm2_setting table to store the tally, we count the tallies in a different system and we only need to issue one query to update the tally every few seconds. Doing it for every email received is very inefficient. Also, the setting_value type is TEXT which is very inefficient to inclement, and will only work if you have turned off strict mode in MySQL https://support.kayako.com/article/472-how-do-i-disable-mysql-strict-mode-on-the-server. In conclusion, the guerrilla_db_redis.go is only an example, you would need to customize the query / saving to fit your own system.
Anyhow, thanks for pointing out these problems. An improved guerrilla_db_redis.go will be pushed soon that also has a query batching optimization.
Thank you @flashmob !
Hello,
I'm attempting to use the guerrilla-db-redis backend. I've populated my mysql DB with the SQL provided in README.md but I still get the following error.
Shouldn't the schema be 1:1 not 15 of 17? (sorry for the poor illustration!):