0

I am trying to create a new column inside the wp_posts table but I am getting the error #1067 - Invalid default value for 'post_date' when I try and save it. What I am trying to do is, I am getting some data from an external API that I am saving in my Database and then I was to be able to check if the data exists in my DB, which is why I am trying to create a column inside the wp_posts table to save the unique ID of the data from the API. The following is the SQL query. I am trying to do this using the PhpMyAdmin.

ALTER TABLE `wp_posts` ADD `apipostid` VARCHAR(20) NULL AFTER `ID`;

1
  • I wouldn't recommend altering the wp_posts table. Instead, add the apipostid as post meta. See, eg, update_post_meta().
    – Pat J
    Commented Oct 13, 2023 at 19:16

1 Answer 1

0

This may not be the best solution. I am not an expert. But the following helped solve my problem and I can add columns using the PhpMyAdmin without getting any errors.

I went over to the SQL tab and then I ran the following query show variables like 'sql_mode'; Then in order to remove i ran the following query set global sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

This helped solve my problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.