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
No explanation generated yet.