Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

330
Visualizações
#1067 - Invalid default value for 'timestamp'

I transferred a WordPress website from a shared hosting plan using Plesk to a VPS server with a newer Plesk version. When trying to upload the MYSQL database I am getting the following error:

Error SQL query: Copy

CREATE TABLE `XZu2B8_wc_reserved_stock` (
  `order_id` bigint(20) NOT NULL,
  `product_id` bigint(20) NOT NULL,
  `stock_quantity` double NOT NULL DEFAULT 0,
  `timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `expires` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`order_id`,`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

MySQL said: Documentation

#1067 - Invalid default value for 'timestamp'

Does anyone have any idea how to fix that?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This was introduced only in mysql 5.6

For mysql 5.5 you need following trigger and you need to remove the DEFAULTs FIRST create the table:

CREATE TABLE `XZu2B8_wc_reserved_stock` (
  `order_id` bigint(20) NOT NULL,
  `product_id` bigint(20) NOT NULL,
  `stock_quantity` double NOT NULL DEFAULT 0,
  `timestamp` datetime NOT NULL,
  `expires` datetime NOT NULL ,
  PRIMARY KEY (`order_id`,`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

Then create the trigger

DELIMITER $$

 CREATE TRIGGER before_insert_XZu2B8_wc_reserved_stock
 BEFORE INSERT ON XZu2B8_wc_reserved_stock
 FOR EACH ROW
 BEGIN
    IF NEW.`timestamp` IS NULL THEN
       SET NEW.`timestamp`= NOW();
    END IF;
    IF NEW.`expires` IS NULL THEN
       SET NEW.`expires`= NOW();
    END IF;
 END$$
 DELIMITER ;
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda