Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with multiple columns having default CURRENT_TIMESTAMP #24

Open
crlcu opened this issue Sep 12, 2019 · 1 comment
Open

Issue with multiple columns having default CURRENT_TIMESTAMP #24

crlcu opened this issue Sep 12, 2019 · 1 comment

Comments

@crlcu
Copy link

crlcu commented Sep 12, 2019

DBD::mysql::st execute failed: Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause at <filename>
@preaction
Copy link
Owner

What version of MySQL are you running? Versions before 5.6.5 do not allow more than one timestamp column with a DEFAULT CURRENT_TIMESTAMP or ON UPDATE CURRENT_TIMESTAMP clauses (see the release notes for MySQL 5.6.5).

If you'd like, you can try this patch. If it works, I can apply it and add support for your version of MySQL.

diff --git a/lib/Minion/Backend/mysql.pm b/lib/Minion/Backend/mysql.pm
index c9020c2..dd67734 100644
--- a/lib/Minion/Backend/mysql.pm
+++ b/lib/Minion/Backend/mysql.pm
@@ -319,8 +319,8 @@ sub register_worker {
   my ($self, $id, $options) = @_;

   my $db = $self->mysql->db;
-  my $sql = q{INSERT INTO minion_workers (id, host, pid, status)
-    VALUES (?, ?, ?, ?)
+  my $sql = q{INSERT INTO minion_workers (id, host, pid, status, started, notified)
+    VALUES (?, ?, ?, ?, NOW(), NOW())
     ON DUPLICATE KEY UPDATE notified=NOW(), host=VALUES(host), pid=VALUES(pid), status=VALUES(status)};
   $db->query($sql, $id, hostname, $$, encode_json( $options->{status} // {} ) );

@@ -1002,7 +1002,7 @@ create table if not exists minion_jobs (
                `id`       serial not null primary key,
                `args`     mediumblob not null,
                `created`  timestamp not null default current_timestamp,
-               `delayed`  timestamp not null default current_timestamp,
+               `delayed`  timestamp not null,
                `finished` timestamp null,
                `priority` int not null,
                `result`   mediumblob,
@@ -1019,7 +1019,7 @@ create table if not exists minion_workers (
                `host`    text not null,
                `pid`     int not null,
                `started` timestamp not null default current_timestamp,
-               `notified` timestamp not null default current_timestamp
+               `notified` timestamp not null
 );

 -- 1 down
@@ -1034,7 +1034,7 @@ alter table minion_jobs add queue varchar(128) not null default 'default';

 -- 4 up
 ALTER TABLE minion_workers MODIFY COLUMN started timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;
-ALTER TABLE minion_workers MODIFY COLUMN notified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE minion_workers MODIFY COLUMN notified timestamp NOT NULL;
 CREATE TABLE IF NOT EXISTS minion_workers_inbox (
   `id` SERIAL NOT NULL PRIMARY KEY,
   `worker_id` BIGINT UNSIGNED NOT NULL,

preaction added a commit that referenced this issue Nov 24, 2019
Versions before 5.6.5 do not support more than one timestamp column with
a default of now. Since we can just send a default, there's no real
need to have defaults...

Fixes #24
Refs #16
larryl pushed a commit to larryl/Minion-Backend-mysql that referenced this issue Dec 19, 2019
  [Fixed]

  - Fixed an issue with InnoDB index sizing and MySQL strict mode.
    Thanks @larryl and Grant Street Group! (Github preaction#24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants