0
CREATE TABLE IF NOT EXISTS `messages` (
    `msg_id` INT(11) NOT NULL AUTO_INCREMENT,
    `msg_user_id` INT(11) NOT NULL,
    `msg_doc_id` INT(11) NOT NULL,
    `msg_question` TEXT NOT NULL,
    `msg_answer` TEXT DEFAULT NULL,
    `msg_files` TEXT DEFAULT NULL,
    `msg_status` TINYINT(3) NOT NULL DEFAULT 1,
    `msg_created_at` DATE NOT NULL DEFAULT CURRENT_TIMESTAMP(),
    PRIMARY KEY (`msg_id`)
)  ENGINE=MYISAM AUTO_INCREMENT=3 DEFAULT CHARSET=LATIN1
nbk
  • 45,398
  • 8
  • 30
  • 47
  • Check this out https://stackoverflow.com/questions/36882149/error-1067-42000-invalid-default-value-for-created-at. – NcXNaV Jun 30 '21 at 16:42
  • `DATE NOT NULL DEFAULT CURRENT_TIMESTAMP(),` Shouldnt it be DateTime ? – Indra Kumar S Jun 30 '21 at 16:46
  • Yes, shouldn't it be DATETIME or TIMESTAMP? Try to change that line to: `'msg_created_at' DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP` – NcXNaV Jun 30 '21 at 16:49
  • Does this answer your question? [How do you set a default value for a MySQL Datetime column?](https://stackoverflow.com/questions/168736/how-do-you-set-a-default-value-for-a-mysql-datetime-column) – nbk Jun 30 '21 at 16:51

0 Answers0