dbDelta does not update table
-
I have study the WordPress docs for dbDelta and the following function DOES create the database table when the plugin is activated.
global $wpdb;
require_once(ABSPATH . ‘wp-admin/includes/upgrade.php’);
$sql = “CREATE TABLE {$wpdb->prefix}gold_member_memberships (
id int(11) NOT NULL AUTO_INCREMENT,
product_name varchar(125) NOT NULL DEFAULT 0,
product_id varchar(20) NOT NULL,
access_to varchar(50) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1″;
dbDelta($sql);However, when I added new fields to the query and reactivated the plugin, the new fields were NOT added.
global $wpdb;
require_once(ABSPATH . ‘wp-admin/includes/upgrade.php’);
$sql = “CREATE TABLE {$wpdb->prefix}gold_member_memberships (
id int(11) NOT NULL AUTO_INCREMENT,
product_name varchar(125) NOT NULL DEFAULT 0,
product_id varchar(20) NOT NULL,
product_id2 varchar(20) NOT NULL,
product_id3 varchar(20) NOT NULL,
product_id4 varchar(20) NOT NULL,
product_id5 varchar(20) NOT NULL,
access_to varchar(50) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1″;
dbDelta($sql);
The topic ‘dbDelta does not update table’ is closed to new replies.