I have added a new field (time_last_seen) in my plugin (v1.1) table then uploaded my plugin as version 1.2 to wordpress svn repository. When I update my plugin from admin panel, it is not creating the field (time_last_seen) in the table.
Here is what I have tried:
function ulh_add_user_logins_table() {
global $wpdb;
$oldVersion = get_option( 'fa_userloginhostory_version', '1.0' );
$newVersion = '1.2';
$charset_collate = $wpdb->get_charset_collate();
$fa_user_logins_table = $wpdb->prefix . "fa_user_logins";
$sql = "CREATE TABLE $fa_user_logins_table (
id int(11) NOT NULL AUTO_INCREMENT,
user_id int(11) ,
`time_login` datetime NOT NULL,
`time_logout` datetime NOT NULL,
`time_last_seen` datetime NOT NULL,
`ip_address` varchar(20) NOT NULL,
`browser` varchar(100) NOT NULL,
`operating_system` varchar(100) NOT NULL,
`country_name` varchar(100) NOT NULL,
`country_code` varchar(20) NOT NULL ,
PRIMARY KEY (`id`)
) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
update_option( 'fa_userloginhostory_version', $newVersion );
}
register_activation_hook(__FILE__, 'ulh_add_user_logins_table');