I am using the latest version of MySql and I tried changing the table to use curtime () or now () or current_timestamp as the default value for the datetime column (created_at, updated_at). For all three changes failed, stating that these are invalid default values. Any ideas what the appropriate default value is generating the current time in the datetime field?
ALTER TABLE `music_library_development`.`albums`
MODIFY COLUMN `created_at` DATETIME NOT NULL DEFAULT current_timestamp,
MODIFY COLUMN `updated_at` DATETIME NOT NULL DEFAULT current_timestamp;
ALTER TABLE `music_library_development`.`albums`
MODIFY COLUMN `created_at` DATETIME NOT NULL DEFAULT now(),
MODIFY COLUMN `updated_at` DATETIME NOT NULL DEFAULT now();
ALTER TABLE `music_library_development`.`albums`
MODIFY COLUMN `created_at` DATETIME NOT NULL DEFAULT curtime(),
MODIFY COLUMN `updated_at` DATETIME NOT NULL DEFAULT curtime();
source
share