Create Table – multiple unique keys
-
I’m working on a plugin that creates a custom table. I’m trying to add a second UNIQUE KEY so the $wpdb->insert will fail if a duplicate value is specified.
dbDelta() has no problem with:$sql = "CREATE TABLE " . $table_name . " ( group_id int unsigned NOT NULL AUTO_INCREMENT, creation_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, group_title tinytext NOT NULL, UNIQUE KEY id (group_id) );";
But the table does not get added if I add a second UNIQUE KEY:
$sql = "CREATE TABLE " . $table_name . " ( group_id int unsigned NOT NULL AUTO_INCREMENT, creation_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, group_title tinytext NOT NULL, UNIQUE KEY id (group_id), UNIQUE KEY group (group_title) );";
What am I missing? Everything I’ve read says you can create multiple UNIQUE KEYs, but I can’t seem to get it working.
Thanks,
Ed
- The topic ‘Create Table – multiple unique keys’ is closed to new replies.