My plugin is supposed to create two tables upon activation. However only the second table is created. Here is the part of my function that creates the tables.
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
global $wpdb;
$ml_wpid = $wpdb->prefix . "ml_wpid";
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE IF NOT EXISTS " . $ml_wpid . " (
`wp_id` mediumint(9) NOT NULL
`name` text NOT NULL
UNIQUE (`char_id`)
) $charset_collate;";
dbDelta( $sql );
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
global $wpdb;
$ml_char = $wpdb->prefix . "ml_char";
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE IF NOT EXISTS " . $ml_char . " (
`char_id` mediumint(9) NOT NULL AUTO_INCREMENT,
`name` text NOT NULL,
UNIQUE (`char_id`)
) $charset_collate;";
dbDelta( $sql );
// starts output buffering
ob_start();
I feel that the reason this is happening is because the $sql variable is being redefined. However I've tried renaming the second table's $sql variable to something different like $sql2 but nothing different happened. Any suggestions? Thanks in advance!