diff --git a/mailpoet/lib/Migrations/Migration_20221110_151621.php b/mailpoet/lib/Migrations/Migration_20221110_151621.php index 4e30a7ddf0..d0c1ed9e8d 100644 --- a/mailpoet/lib/Migrations/Migration_20221110_151621.php +++ b/mailpoet/lib/Migrations/Migration_20221110_151621.php @@ -16,8 +16,8 @@ class Migration_20221110_151621 extends Migration { name varchar(255) NOT NULL, author bigint NOT NULL, status varchar(255) NOT NULL, - created_at timestamp NOT NULL, - updated_at timestamp NOT NULL, + created_at timestamp NULL, -- must be NULL, see comment at the top + updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, activated_at timestamp NULL, deleted_at timestamp NULL, PRIMARY KEY (id) @@ -29,8 +29,8 @@ class Migration_20221110_151621 extends Migration { id int(11) unsigned NOT NULL AUTO_INCREMENT, automation_id int(11) unsigned NOT NULL, steps longtext, - created_at timestamp NOT NULL, - updated_at timestamp NOT NULL, + created_at timestamp NULL, -- must be NULL, see comment at the top + updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id), INDEX (automation_id) ) {$charsetCollate}; @@ -51,8 +51,8 @@ class Migration_20221110_151621 extends Migration { version_id int(11) unsigned NOT NULL, trigger_key varchar(255) NOT NULL, status varchar(255) NOT NULL, - created_at timestamp NOT NULL, - updated_at timestamp NOT NULL, + created_at timestamp NULL, -- must be NULL, see comment at the top + updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, subjects longtext, next_step_id varchar(255), PRIMARY KEY (id), diff --git a/mailpoet/tests/integration/API/JSON/v1/SetupTest.php b/mailpoet/tests/integration/API/JSON/v1/SetupTest.php index b1bb37e3c4..1ee75b167c 100644 --- a/mailpoet/tests/integration/API/JSON/v1/SetupTest.php +++ b/mailpoet/tests/integration/API/JSON/v1/SetupTest.php @@ -16,6 +16,15 @@ use MailPoet\Settings\SettingsRepository; use MailPoet\Subscription\Captcha; use MailPoet\WP\Functions as WPFunctions; +/** + * The "created_at" column must be NULL in some tables to avoid "there can be only one + * TIMESTAMP column with CURRENT_TIMESTAMP" error on MySQL version < 5.6.5 that occurs + * even when other timestamp is simply "NOT NULL". + * + * Additionally, having multiple timestamp columns with "NOT NULL" seems to produce the + * following error in some SQL modes: + * SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'updated_at'" + */ class SetupTest extends \MailPoetTest { public function _before() { parent::_before();