I'm following an online course which includes creating a WordPress plugin. There was a problem when I tried, following the instructions (and using the provided code to exclude any error on my side) to create a custom table. This is a section of the original code:
$sql = "CREATE TABLE {$wpdb->prefix}ssp_survey_responses (
id mediumint(11) UNSIGNED NOT NULL AUTO_INCREMENT,
ip_address varchar(32) NOT NULL,
survey_id mediumint(11) UNSIGNED NOT NULL,
response_id mediumint(11) UNSIGNED NOT NULL,
created_at TIMESTAMP DEFAULT '1970-01-01 00:00:00',
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id),
UNIQUE INDEX ix (ip_address,survey_id)
) $charset_collate;";
I tried to insert the SQL directly in the MySQL database, cleaning the code:
CREATE TABLE ssp_survey_responses (
id mediumint(11) UNSIGNED NOT NULL AUTO_INCREMENT,
ip_address varchar(32) NOT NULL,
survey_id mediumint(11) UNSIGNED NOT NULL,
response_id mediumint(11) UNSIGNED NOT NULL,
created_at TIMESTAMP DEFAULT '1970-01-01 00:00:01',
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id),
UNIQUE INDEX ix (ip_address,survey_id)
)
and MySQL gives this error
#1067 - Invalid default value for 'created_at'
Might the local settings of MySQL (Italian) be creating any problem?
The MySQL version is: 5.7.21-0ubuntu0.16.04.1 - (Ubuntu).
PHP Version 7.0.22.
WordPress version: 4.9.2.
Thank you.