Looking at the SQL query in $createSQL,
-
ENGINE=InnoDB" . $wpdb->get_charset_collate() . " AUTO_INCREMENT=1;yields to:Error in query (1286): Unknown storage engine ‘InnoDBDEFAULT’
To fix it, add a space between the
ENGINE=InnoDB(the storage engine) and" . $wpdb->get_charset_collate()(the charset). -
You have defined the column
idasAUTO_INCREMENT, but the column is not a key, and that yields to the following error:Error in query (1075): Incorrect table definition; there can be only
one auto column and it must be defined as a keyTo fix it, define the column
idas a key using eitherPRIMARY KEY (id)orKEY(id).
So, here’s the fixed code (or SQL query), tried and tested working on WordPress 4.9.8:
$createSQL = "
CREATE TABLE `". $wpdb->prefix ."_book_ratings` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`book_id` bigint(20) UNSIGNED NOT NULL,
`rating` float(3.1) UNSIGNED NOT NULL,
`user_ip` varchar(32) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB " . $wpdb->get_charset_collate() . " AUTO_INCREMENT=1;
";
If that doesn’t work for you, follow the guides here, such as use two spaces between the words PRIMARY KEY and the definition of your primary key.