当我尝试激活自定义插件时,收到以下错误:
WordPress数据库错误为查询定义的多个主键ALTER TABLE temp CHANGE COLUMN
id
id int(11)UNSIGNED AUTO_INCREMENT PRIMARY
private function runDbMigration_20() {
$sql = "CREATE TABLE " . PREFIX . "subscribers (
id int(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name tinytext NOT NULL,
email text NOT NULL,
secretkey text NOT NULL,
random_key text NOT NULL,
onehourmailsent int(1) NOT NULL DEFAULT 0,
onedaymailsent int(1) NOT NULL DEFAULT 0,
wbstartingmailsent int(1) NOT NULL DEFAULT 0,
replaymailsent int(1) NOT NULL DEFAULT 0,
temp_id int(11) NOT NULL,
exact_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
watch_day varchar(3),
watch_time time,
time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
last_seen datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
active int(1) UNSIGNED NOT NULL DEFAULT 1,
high_five int(1) UNSIGNED NOT NULL DEFAULT 0,
attended int(1) UNSIGNED NOT NULL DEFAULT 0
)" . $this->CHARSET_COLLATE . ";";
return $this->calldbDelta($sql);
}
请问,有人可以帮我解决这个错误吗?
答案 0 :(得分:0)
最后添加 PRIMARY KEY(id)解决了错误
private function runDbMigration_20() {
$sql = "CREATE TABLE " . WSWEB_DB_TABLE_PREFIX . "subscribers (
id int(11) UNSIGNED AUTO_INCREMENT,
name tinytext NOT NULL,
email text NOT NULL,
secretkey text NOT NULL,
random_key text NOT NULL,
onehourmailsent int(1) NOT NULL DEFAULT 0,
onedaymailsent int(1) NOT NULL DEFAULT 0,
wbstartingmailsent int(1) NOT NULL DEFAULT 0,
replaymailsent int(1) NOT NULL DEFAULT 0,
temp_id int(11) NOT NULL,
exact_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
watch_day varchar(3),
watch_time time,
time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
last_seen datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
active int(1) UNSIGNED NOT NULL DEFAULT 1,
high_five int(1) UNSIGNED NOT NULL DEFAULT 0,
attended int(1) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (id)
)" . $this->CHARSET_COLLATE . ";";
return $this->calldbDelta($sql);
}