I know the specifics of using dbDelta and I've read the documentation (http://codex.wordpress.org/Creating_Tables_with_Plugins), read other answers to the question I'm asking, but I'm just not seeing what I'm doing wrong. When I var_dump the result of dbDelta, I get no errors, just "array(1) { [0]=> string(48) "Added index wp_ovrdrvamdata PRIMARY KEY id (id)" }
" or some other untrue statement. The table just is not being created.
Here is the code/query:
function ovrdrv_asset_install() {
global $wpdb;
global $ovrdrv_am_db_version;
$wpdb->show_errors();
$data_table_name = $wpdb->prefix . 'ovrdrvamdata';
$sql = "CREATE TABLE ". $data_table_name ." (
id int(9) NOT NULL AUTO_INCREMENT,
data varchar(255) NOT NULL,
form_id smallint(4) NOT NULL,
PRIMARY KEY id (id)
);";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
var_dump(dbDelta( $sql ));
$wpdb->print_error();
add_option('ovrdrv_am_db_version', $ovrdrv_am_db_version);
}
EDIT: After turning on WPDB errors, I'm getting these errors:
WordPress database error: [Multiple primary key defined]
ALTER TABLE wp_ovrdrvamdata ADD PRIMARY KEY id (id) /* From [client.staging.wpengine.com/wp-admin/plugins.php?activate=true&plugin_status=all&paged=1&s=] in [/nas/wp/www/staging/client/wp-content/plugins/client-plugin/table-creation.php:22] */
array(1) { [0]=> string(48) "Added index wp_ovrdrvamdata PRIMARY KEY id (id)" }
WordPress database error: [Multiple primary key defined]
ALTER TABLE wp_ovrdrvamdata ADD PRIMARY KEY id (id) /* From [client.staging.wpengine.com/wp-admin/plugins.php?activate=true&plugin_status=all&paged=1&s=] in [/nas/wp/www/staging/client/wp-content/plugins/client-plugin/table-creation.php:22] */
It seems as if it's trying to add the primary key multiple times or something, even though the table does not exist yet.
Any help would be appreciated.