PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Invalid Default Value for 'created_at' (FIX)

ALTER TABLE `table_name` 
MODIFY created_at TIMESTAMP,
MODIFY updated_at TIMESTAMP
DEFAULT CURRENT_TIMESTAMP 
NOT NULL

There are multiple times where I need to add a new row to my sequel pro database and I get an error message back saying: invalid default value for 'created_at', I'll then try and update the created_at field with CURRENT_TIMESTAMP and I get the error: invalid default value for 'updated_at'. I find myself in the TIMESTAMP LOOP from hell.

Luckily enough, there is a simple solution to update both of these rows at the same time. You can use the following sequel query to add CURRENT_TIMESTAMP to each row and your problem will be solved :)

ALTER TABLE `table_name` 
MODIFY created_at TIMESTAMP,
MODIFY updated_at TIMESTAMP
DEFAULT CURRENT_TIMESTAMP 
NOT NULL

Hope that helps you escape the TIMESTAMP loop from hell :D

BETA Snippet explanation automatically generated by OpenAI:

No explanation generated yet.

Snippet By Dev Dojo

ยท

Created June 12th, 2021

ยท

Report Snippet