Why this function not working for install database on plugin activation

I followed codex instructions from wordpress site but for some reason it’s not working for me and i can’t understand why is there any debug settings or options to activate to explain me where i go wrong.

Here is hook on plugin activation to install database but it’s not working

Read More
global $evg_version;
$evg_version = '1.0';

//Install database when plugin activated
function evg_activate() {
global $wpdb;
global $evg_version;

$evg_table = $wpdb->prefix . 'evg_feeds';
$evg_table_charset = $wpdb->charset;
$evg_table_colate = $wpdb->colate;
//Create table
$sql = "CREATE TABLE $evg_table (
    id bigint(20) NOT NULL AUTO_INCREMENT,
    feedname varchar(200) NOT NULL,
    provider varchar(20) NOT NULL,
    searchterm varchar(200) NOT NULL,
    numvideos int(10) NOT NULL,
    poststatus varchar(20) NOT NULL,
    commentstatus varchar(20) NOT NULL,
    postauthor varchar(20) NOT NULL,
    feedstatus int(5) NOT NULL DEFAULT '1',
    UNIQUE KEY id (id)
    ) DEFAULT CHARACTER SET $evg_table_charset  COLLATE $evg_table_colate ;";

require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);

add_option('evg_version', $evg_version);
}
register_activation_hook( __FILE__, 'evg_activate' );

add_option works and it updates version just it doesn’t install database.

Related posts