splitbrain / dokuwiki-plugin-statistics

Gather usage/view statistics of a DokuWiki
http://www.dokuwiki.org/plugin:statistics
6 stars 17 forks source link

DB Error: Field 'dt' doesn't have a default value REPLACE INTO stats_lastseen SET `user` = 'user' #64

Closed nickgreen43 closed 2 years ago

nickgreen43 commented 2 years ago

This error keeps showing when logging in for every user in our system. It's caused by the Statistics plugin (https://www.dokuwiki.org/plugin:statistics).

I tried following this https://github.com/splitbrain/dokuwiki-plugin-statistics/issues/50 but I was not able to find the my.cnf config file.

Re-installing didn't help either. Only disabling the plugin makes the error go away.

nickgreen43 commented 2 years ago

I think I found a resolution to the error... since the "stats_lastseen" table (from https://github.com/splitbrain/dokuwiki-plugin-statistics/blob/master/db.sql) has NOT NULL but no default placed, it was erroring out. I added the below statement to alter the table to be more like the 'stats_access' table. Can't say if there are repercussions yet or not but so far so good at least the error is not showing up on the dokuwiki for users anymore.

ALTER TABLE "stats_lastseen" CHANGE COLUMN "dt" "dt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;

note: if you copy paste this, you may need to replace the double quotes (") with single quotes (') around each table and column name.

TafkaMax commented 1 year ago

I also had the same problem. My fix command looked similar: ALTER TABLE stats_lastseen MODIFY dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;